请问如何转化URL编码?
例如编程实现把
%68%74%74%70%3A%2F%2F%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D
转化成
http://www.google.com这种形式是什么编码?谢谢
例如编程实现把
%68%74%74%70%3A%2F%2F%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D
转化成
http://www.google.com这种形式是什么编码?谢谢
inline BYTE toHex(const BYTE &x)
{
return x>9?x+55:x+48;
}void UrlEncode(LPBYTE in,LPBYTE out)
{
if(out)
{
while (*in)
{
if(isalnum(*in))
*out++ = *in;
else
if(isspace(*in))
*out++ = '+';
else
{
*out++ = '%';
*out++ = toHex(*in>>4);
*out++ = toHex(*in%16);
}
in++;
}
*out = '\0';
}
}
CString szTemp;
char buff[100] = {0};
int i = 0;
int k = 0;
while(AfxExtractSubString( szTemp, szData, i, '%'))
{
if(!szTemp.IsEmpty ())
buff[k++] = (char)strtoul(szTemp, NULL, 16);
i++;
}
msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/shlwapi/path/urlunescape.asp