uj5u.com熱心網友回復:
用UnicodeString來定義變數試試uj5u.com熱心網友回復:
又是字符集的問題,樓主,你把L"字串"改成_T("字串")形式再試試uj5u.com熱心網友回復:
WideCharToMultiByteMultiByteToWideChar
可以解決你的問題。研究一下用法
uj5u.com熱心網友回復:
樓主的控制臺默認活動代碼頁不是簡體中文吧,運行 chcp 看看顯示多少,運行 chcp 936 更改成簡體中文的代碼頁就OK了。uj5u.com熱心網友回復:
用我這個自寫函式試試吧~std::string UTF8_To_string(const std::string & str)
{
int nwLen = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, NULL, 0);
wchar_t * pwBuf = new wchar_t[nwLen + 1];//一定要加1,不然會出現尾巴
memset(pwBuf, 0, nwLen * 2 + 2);
MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), pwBuf, nwLen);
int nLen = WideCharToMultiByte(CP_ACP, 0, pwBuf, -1, NULL, NULL, NULL, NULL);
char * pBuf = new char[nLen + 1];
memset(pBuf, 0, nLen + 1);
WideCharToMultiByte(CP_ACP, 0, pwBuf, nwLen, pBuf, nLen, NULL, NULL);
std::string retStr = pBuf;
delete[]pBuf;
delete[]pwBuf;
pBuf = NULL;
pwBuf = NULL;
return retStr;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/78749.html
上一篇:VC呼叫Documents::Open打開一個未被關閉的word檔案 導致程式崩潰
下一篇:Opengl程式錯誤:fatal error C1083: Cannot open include file: 'GL/glut.h': No such fil
