Sorry, here is the corrected example: std::string aFileName = "E:/Some/File.txt"; std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> converter; std::wstring vFileName = converter.from_bytes(aFileName); FILE *in_stream = _wfopen(vFileName.c_str(), L"rb"); // in_stream is NULL here
The same code with fopen() on the original std::string works: std::string aFileName = "E:/Some/File.txt"; FILE *in_stream = fopen(aFileName.c_str(), "rb"); // in_stream is a correctly opened file here All the best, Mario Emmenlauer On 21.03.2017 00:27, David Grayson wrote: > You must be doing something wrong because aFileName is set but not used in the > first example. > > You should try doing something like _wfopen(L"E:/Some/File.txt", L"rb"); so > that > you can verify that _wfopen works without strange C++ stuff. > > --David > > On Mon, Mar 20, 2017 at 4:21 PM, Mario Emmenlauer <ma...@emmenlauer.de > <mailto:ma...@emmenlauer.de>> wrote: > > > I have a problem with code that is using _wfopen() on Windows. Should it > work with MSYS2? I have the following code that fails: > [...] > > Is that to be expected, or am I doing something wrong? > > All the best, > > Mario Emmenlauer ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Msys2-users mailing list Msys2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/msys2-users