CStdioFile WriteString 无法写入中文 已解决

转载:https://blog.csdn.net/mowwwcom/article/details/39555927
已亲自测试确实是这个问题,VS2010对Unicode汉字字符输出的支持还不是很好。

解决方法:

使用setlocale语句设定区域。

需要包含的头文件:

#include <locale> 

CStdioFile file;

CFileException pError;

setlocale( LC_CTYPE, (“chs”)); 

if(!file.Open(_T(“ttt.txt”), CFile::modeReadWrite | CFile::modeCreate, &pError))
{
MessageBox(_T(“Tip”), _T(“open failed!”), MB_ICONWARNING);
}

file.WriteString(_T(” dear 静 where are you “));
file.Close();
发布了7 篇原创文章 · 获赞 50 · 访问量 15万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章