C++爬虫原理(五):编码和解码URL,UTF-8方式,网上大多数是ansi方式的编码,即:UTF-8,UrlEncode编码/UrlDecode解码:一个CString版的代码如下(项目需要随手写了一个):CString CTestDlg::URLEncode(CString str)
{
int len = MultiByteToWideChar(CP_ACP,0,str.GetBuffer(0),-1,NULL,0);
str.ReleaseBuffer();
wchar_t *unicode = new wchar_t[len];
MultiByteToWideChar(CP_ACP,0,str.GetBuffer(0),-1,unicode,len);
str.ReleaseBuffer();
len = WideCharToMultiByte(CP_UTF8,0,unicode,-1,NULL,0,NULL,NULL);
unsigned char *newChar = new unsigned char[len];
WideCharToMultiByte(CP_UTF8,0,unicode,-1,(LPSTR)newChar,len,NULL,NULL);
CString newStr="";
CString tempStr="";
char
...
继续阅读
(45)