16,548
社区成员




CString txt = _T("\u6211\u4ECA\u5E7430\u5C81\u4E86");
inline BYTE HexCharToInt(TCHAR c)
{
if ((c >= '0') && (c <='9'))
return (c - '0');
else if ((c >='a') && (c <='f'))
return (c - 'a' + 10);
else if ((c >='A') && (c <='F'))
return (c - 'A' + 10);
else
return 0;
}
CString UTF8UrlParser(CString strIN)
{
CStringW res;
const TCHAR* pSrc = strIN;
wchar_t *pBuf = res.GetBuffer(strIN.GetLength());
while (*pSrc)
{
if((pSrc[0] == '\\') && (pSrc[1] == 'u'))
{
*pBuf++ = (wchar_t)(HexCharToInt(pSrc[2])*0x1000 + HexCharToInt(pSrc[3])*0x100 + HexCharToInt(pSrc[4])*0x10 + HexCharToInt(pSrc[5]));
pSrc += 6;
}
else
{
*pBuf++ = *pSrc++;
}
}
*pBuf = 0x00;
return CString((const wchar_t*)res);
}