Click to See Complete Forum and Search --> : basic_stream and UTF8 filenames


EoF
November 17th, 2007, 02:52 PM
Hello,

for the past few days I've been trying to get an answer to this. How can I open a file that has Unicode characters in its name using ifstream - the filename is stored in a wstring? I can't use MFC so CFile won't do. I did take a look at wifstream, but I got the same problem as regular ifstream, it takes a char* as the file name, not a w_char*.
The only way I can think of is to find the alternate name of the file using FindFirstFileEx/FindNextFile, but this is not good if I have the full path and one of the parent folders contains Unicode characters.

Any help would be greatly appreciated.

EoF
November 19th, 2007, 01:16 AM
Well, I ended up calling GetShortPathName() and using the result as a regular string and passing it to the ifstream constructor.

Marc G
November 19th, 2007, 02:10 AM
[ moved thread ]