16,472
社区成员
发帖
与我相关
我的任务
分享
CString strText(_T(""));
CString strTemp(_T(""));
char szText[] = "http://www.baidu.com/¿¨_Ôζ IðBÈéƬ.pdf";
wchar_t* szBuf = NULL;
int nLen =MultiByteToWideChar(CP_ACP, 0, szText, -1, szBuf, 0);
szBuf = new wchar_t[nLen];
memset(szBuf, 0, nLen * sizeof(wchar_t));
MultiByteToWideChar(CP_ACP, 0, szText, -1, szBuf, nLen);
char* buf = NULL;
nLen =WideCharToMultiByte(CP_UTF8, 0, szBuf, -1, buf, 0, NULL, NULL);
buf = new char[nLen];
memset(buf, 0, nLen * sizeof(char));
WideCharToMultiByte(CP_UTF8, 0, szBuf, -1, buf, nLen, NULL, NULL);
char* p = buf;
while(*p)
{
BYTE ch = *p;
if(IsDBCSLeadByte(ch))
{
strTemp.Format(_T("%%%X"), ch);
strText += strTemp;
}
else
{
strText += (char)ch;
}
p++;
}
delete[] buf;
buf = NULL;
delete[] szBuf;
szBuf = NULL;
AfxMessageBox(strText);