Search code examples
c++windowsgccunicodewide-api

Opening fstream with file with Unicode file name under Windows using non-MSVC compiler


I need to open a file as std::fstream (or actually any other std::ostream) when file name is "Unicode" file name.

Under MSVC I have non-standard extension std::fstream::open(wchar_t const *,...)? What can I do with other compilers like GCC (most important) and probably Borland compiler.

I know that CRTL provides _wfopen but it gives C FILE * interface instead of io-streams, maybe there is a non-standard way to create io-stream from FILE *? Is there any boost::ifstream with MSVC like extension for Windows?


Solution

  • Currently there is no easy solution.

    You need to create your own stream buffer that uses _wfopen under the hood. You can use for this for example boost::iostream