轉載: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();