File truncates after hitting a wide character

112 views Asked by At

While trying to write some wide characters to a file, all output to the file stops after those characters. I don't know what's going on.

wofstream file("c:\\test.txt");

file << L"seen" << L"您好" << "unseen";
1

There are 1 answers

3
rubenvb On

Non-ASCII characters in source code are parsed in an implementation defined way. Use either hex sequences or the newer (post-c99 or C++11) unicode character literals and use their UTF-8/16/32 codepoint representations.

This is implementation defined behavior, so unless you are absolutely sure you compiler does what you expect, don't do this.