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萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章