方法一:
字符集转换: utf8 to uni.
std::wstring utf8_to_uni(const char *in)
{
return _to_uni(CP_UTF8, in); // ansi to uni: CP_ACP
}
std::wstring _to_uni(unsigned int acp, const char *lpa)
{
int nChars = strlen(lpa)+1;
wchar_t *lpw = new wchar_t[nChars];
lpw[0] = 0;
int ret = MultiByteToWideChar(acp, 0, lpa, -1, lpw, nChars);
if(ret == 0)
{
delete []lpw;
return L"";
}
std::wstring wstrlpw = lpw;
delete []lpw;
return wstrlpw;
}
方法二:
打开工程属性面板:"General" -> "Character Set" 设置为:"Use Multi-Byte Character Set" 。
来源:CSDN
作者:m_zhu
链接:https://blog.csdn.net/m_zhu/article/details/103593314