问题
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:
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.
来源:https://stackoverflow.com/questions/7906713/file-truncates-after-hitting-a-wide-character