/*****************************
字符转换 ANSI 转UTF-8
*****************************/
long ANSItoUTF8(CString bufRecv,char* utf8_buf)
{
long unicodeLen = ::MultiByteToWideChar(CP_UTF8, 0, bufRecv, -1, NULL, 0);
wchar_t *pUnicode = new wchar_t[unicodeLen+1];
memset(pUnicode, 0, unicodeLen * sizeof(wchar_t));
::MultiByteToWideChar(CP_UTF8, 0, bufRecv, -1, (LPWSTR)pUnicode, unicodeLen);
wstring rt_utf8 = pUnicode;
delete pUnicode;
long utf8length = rt_utf8.length();
CString str(rt_utf8.c_str());
memset(utf8_buf,0,sizeof(utf8_buf));
strcat(utf8_buf, (LPSTR)(LPCTSTR)(str));
return rt_utf8.length();
}
字符转换 ANSI 转UTF-8
最新推荐文章于 2024-02-02 14:18:02 发布