CStringUtf8ToUnicode

CString CStringUtf8ToUnicode( CString Utf8 )
{
int wLen = 0;
CString strUnicode;
LPSTR pBufChar = NULL;
LPWSTR pBufWchar = NULL; //CString to char
wLen = WideCharToMultiByte(CP_ACP, 0, Utf8, -1, NULL, 0, NULL, NULL);
pBufChar = new char[wLen + 1];
memset( pBufChar , 0, wLen + 1 );
WideCharToMultiByte(CP_ACP, 0, Utf8, -1, pBufChar, wLen, NULL, NULL); //char to Unicode
wLen = MultiByteToWideChar(CP_UTF8, 0, pBufChar, -1, NULL, NULL);
pBufWchar = new wchar_t[wLen];
memset(pBufWchar, 0, wLen * sizeof(wchar_t));
MultiByteToWideChar(CP_UTF8, 0, pBufChar, -1, pBufWchar, wLen); strUnicode = CString(pBufWchar);
if( pBufChar ) delete pBufChar;
if( pBufWchar ) delete pBufWchar; return strUnicode;
}
上一篇:Lua在Windows下的配置、安装、运行


下一篇:Dynamics AX 2012 R2 AIF自定义服务中的事务回滚Bug