文件在击中宽字符后截断 [英] File truncates after hitting a wide character
本文介绍了文件在击中宽字符后截断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在尝试向文件中写入某些宽字符时,所有输出到该文件的输出将在这些字符之后停止。我不知道发生了什么。
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";
推荐答案
源代码中的非ASCII字符实现定义方式。使用十六进制序列或更新的(后c99或C ++ 11)unicode字符文字,并使用其UTF-8/16/32代码点表示。
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.
这篇关于文件在击中宽字符后截断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文