
On Wed, Feb 10, 2010 at 7:21 AM, Paul
Hi, What is the best way for me to use boost::filesystem::wpath with a 3rd party C library that expects a const char* filename, on Windows? On linux, its simple: my_file.to_external_string() but on windows that gives me a wide-character string. So far the only thing I can think of is to roll my own wstring --> UTF8 conversion function, but I'm not even sure that is correct (will fopen() work with UTF-8 encoded filenames on windows?). thanks,
That is correct. On Windows XP and higher *all* file function use wide-character strings. Their are ascii versions of the same functions, but you can see the implementation and they just convert the string to a wide then call the normal function, hence having it wide in the first place saves you time. It seems pretty stupid to convert from wide to ascii just to have the system waste even more time converting from ascii back to wide. I do not think file functions will work with all UTF-8 though as UTF-8 support in the Windows kernel is... lacking...