My wofstream is truncating when trying to write wide characters to the file.
my_file << L"something";
wstring foo = //get a value from the registry ..
// foo contains 您好
my_file << foo;
my_file << "stuff that will never be seen";
The badbit (or other error bit) is being set in your stream, rendering it useless for any operation afterwards. This is probably on the border of implementation defined behavior (especially for wchar_ts). It just won't work the way you want it to.
The largest probability for the error is that the characters don't fit in one 2-byte wchar_t, making Microsoft's STL choke.
The badbit (or other error bit) is being set in your stream, rendering it useless for any operation afterwards. This is probably on the border of implementation defined behavior (especially for
wchar_t
s). It just won't work the way you want it to.The largest probability for the error is that the characters don't fit in one 2-byte
wchar_t
, making Microsoft's STL choke.