unicode字符集下CStdioFile无法写入中文的解决方案

    CStdioFile file;
    file.Open(_T("c:\\a.txt"),CFile::modeCreate |CFile::modeReadWrite);
    file.WriteString(_T("hello world ,第一句话"));
    file.Flush();
    file.Close();

image

默认状态下,中文无法显示。

    _tsetlocale( LC_CTYPE, _T("chs"));//设置语言环境为中文。如果主机安装的是中文版windows系统,可以设置_tsetlocale( LC_ALL, _T(""))为系统默认语言环境;
    CStdioFile file;
    file.Open(_T("c:\\a.txt"),CFile::modeCreate |CFile::modeReadWrite);
    file.WriteString(_T("hello world ,第一句话"));
    file.Flush();
    file.Close();
image
posted @ 2014-07-29 14:10  忆寒  Views(432)  Comments(0Edit  收藏  举报