
On 11 February 2010 06:19, OvermindDL1
Hi, What is the best way for me to use boost::filesystem::wpath with a 3rd
On Wed, Feb 10, 2010 at 7:21 AM, Paul
wrote: 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...
This sounds like interacting with many C programs that open files could be a big problem... Take for example, zlib http://zlib.net/manual.html#Gzip fs::wpath my_path = whatever; gzFile f = gzopen( my_path.NARROW(), "r" ); ?? In zlib's case, I might be saved because I can call gzopen on a file-descriptor, but there are other libraries (one of which I am using) that will only accept a char* filename... What do I do? thanks, Paul