Possible Duplicate:
Opening fstream with file with Unicode file name under Windows using non-MSVC compiler
I have been trying to find a simple way to open a file with non-ASCII characters in its filename in Windows with GCC. Microsoft's STL provides wstring
overloads for the fstream
classes, but Standard C++ does not, because `wchar_t´ isn't well-defined.
I'm looking for a way to open a fstream
when given a std::wstring
for a filename, in Standard C++ and Win32 API.
I do not want to create my own streambuf subclass that takes a std::wstring
and imitates fstream
. I do need to imitate the fstream::open(const std::wstring &)
(or whatever it's declared as) function, so I can open weirdly named files without a hitch.
I have already thought of using the short DOS 8.3 filenames, but the GetShortPathName takes and outputs wide strings, unusable for the STL constructor/open function. I do have methods in place to convert to different codepages, so perhaps converting the wide string to local codepage will give the correct 8-bit string that allows me to open an fstream
?