BOOL Decodeurl (char *src, char *url, int maxlen) {if (NULL = = URL | | NULL = = SRC) {return false; } if (MaxLen = = 0) {return false; } char *p = SRC; Used to loop int i = 0; I used to control the URL array/* Temporarily save URL encoded data such as:%1A%2B%3C */char t = ' + '; while (*p! = ' \ ' && maxlen--) {if (*p = = 0x25)//0x25 = '% ' { /* The following are the usual uppercase letters, lowercase letters, numbers in hexadecimal numbers * * * if (p[1] >= ' A ' && p[1] <= ' Z ')//capital letters {t = p[1]-' A ' + 10; A = 10, same as} else if (p[1] >= ' A ' && p[1] <= ' z ')//lowercase Letter {t = p[1]-' a ' + 10; } else if (p[1] >= ' 0 ' && p[1] <= ' 9 ')//number {T = P[1]-' 0 '; } t *= 16; Put the number on 10 bit up if (p[2] >= ' A ' && p[2] <= ' Z ')//capital Letter { T + = p[2]-' A ' + 10; } else if (p[2] >= ' A ' && p[2] <= ' z ')//lowercase letter {T + = P[2]-' a ' + 10; } else if (p[2] >= ' 0 ' && p[2] <= ' 9 ')//number {T + = p[ 2]-' 0 '; }//To this composite a hexadecimal number url[i] = t; p + = 3, i++; } else {//does not have URL-encoded data//' + ' special handling. It's equivalent to a space I F (*p! = ' + ') {url[i] = *p; } else {url[i] = 0x20; } i++; p++; }} Url[i] = ' + '; Terminator return true; }
VC Implementation URL Codec