mfc cstdioFile reader读取中文字符出现问题的解决方法

void CMfcReaderDlg::OnBnClickedButton1()
{
    // TODO:  在此添加控件通知处理程序代码
    UpdateData(TRUE);
    //using chinese character reader way.
    char* old_locale = _strdup(setlocale(LC_CTYPE, NULL));
    setlocale(LC_CTYPE, "chs");


    CStdioFile stdFile(L"test.txt", CFile::modeRead);
    CString strBuf;
    while(stdFile.ReadString(strBuf))
    {

        MessageBox(strBuf);

    }

    stdFile.Close();

    //release chinese character translation
    setlocale(LC_CTYPE, old_locale);
    free(old_locale);

}

你可能感兴趣的:(mfc)