K
kaalus
Hi All,
I just tried to use wide streams with C++. But something really strange
is happening (my compiler is MSVC, wchar_t size is 2 bytes):
std::wofstream s("a");
s << L'A';
s.close();
Result: file 'a' is created and it contains 1 byte. I expected it
should contain 2 bytes...? So I tried what happens when character is
outside 0-255 range:
std::wofstream s("a");
s << L'.'; // in place of . there is unicode character U+2666
Result: Writing failed and stream bad() flag is set. What's wrong here,
isn't wofstream supposed to write wide characters to stream?
cheers,
Marcin
btw. I can write wchar_t values using regular ofstream, and I get 2
bytes per character as expected. But wofstream doesn't seem to work.
I just tried to use wide streams with C++. But something really strange
is happening (my compiler is MSVC, wchar_t size is 2 bytes):
std::wofstream s("a");
s << L'A';
s.close();
Result: file 'a' is created and it contains 1 byte. I expected it
should contain 2 bytes...? So I tried what happens when character is
outside 0-255 range:
std::wofstream s("a");
s << L'.'; // in place of . there is unicode character U+2666
Result: Writing failed and stream bad() flag is set. What's wrong here,
isn't wofstream supposed to write wide characters to stream?
cheers,
Marcin
btw. I can write wchar_t values using regular ofstream, and I get 2
bytes per character as expected. But wofstream doesn't seem to work.