CString使用Format转换字符出现乱码

⌚Time: 2022-10-16 17:24:06

👨‍💻Author: Jack Ge

CString使用Format转换char*字符出现乱码


strTemp.Format(L"%s",strCH);

解决办法,将char转化成wchar


TCHAR wstrCH[1024] = {0};

mbstowcs( wstrCH, strCH, 1024 );

strTemp.Format(L"%s",wstrCH);

设置wchar支持中文


setlocale(LC_ALL, "chs");