File truncates after hitting a wide character

放肆的年华 提交于 2019-12-11 13:12:05

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!