将unicode字符串转换为Unicode编码值


CString strToUnicode(char* src)

{
CString strTmp = _T("");   
DWORD dwNum;
dwNum = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)src, -1, NULL, 0);
wchar_t *pwText;
pwText = new wchar_t[dwNum];
dwNum = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)src, -1, pwText, dwNum); 
CString m_Unicode = L"";

for(int i = 0; i < (int)dwNum - 1; i++)  
{
strTmp.Format(L"\\u%04X", pwText[i]);
m_Unicode += strTmp;
}
delete[] pwText; 

return m_Unicode;
}

你可能感兴趣的:(CC++语言)