I\'m trying to write a wstring to file with ofstream in binary mode, but I think I\'m doing something wrong. This is what I\'ve tried:
ofstream outFile(\"tes
I suspect that sizeof(wchar_t) is 4 in your environment - i.e. it's writing out UTF-32/UCS-4 instead of UTF-16. That's certainly what the hex dump looks like.
That's easy enough to test (just print out sizeof(wchar_t)) but I'm pretty sure it's what's going on.
To go from a UTF-32 wstring to UTF-16 you'll need to apply a proper encoding, as surrogate pairs come into play.