19,502
社区成员
发帖
与我相关
我的任务
分享
while(true)
{//-------------读串口---------------------
ReadFile(hCom, &tmp, 64, &cBytes, NULL );
readQRCStr = en.CharsToCStringUTF8(tmp);
if(readQRCStr.GetLength() > 0)
{
file.Write(tmp, sizeof(tmp));
SendMessage(my_hwnd,WM_READEDQR, 0, 0);
}
}
在这转了编码格式,有什么问题么?
CString CharsToCStringUTF8(const char* chars)
{
int unicodeLen = MultiByteToWideChar(CP_UTF8, 0, chars , -1, NULL, 0);
WCHAR *pUnicode = new WCHAR[unicodeLen + 1];
memset(pUnicode,0,(unicodeLen+1)*sizeof(wchar_t));
MultiByteToWideChar(CP_UTF8,0,chars,-1, pUnicode,unicodeLen);
CString str(pUnicode);
delete []pUnicode;
return str;
}