Char Dec2hexchar (short int n) {if (0 <= n && n <= 9) {return char (' 0 ') + N); } else if (<= n && n <=) {return char (short (' A ') + n-10); } else {return char (0); }}} short int hexchar2dec (char c) {if (' 0 ' <=c && c<= ' 9 ') {RET Urn Short (c ' 0 '); } else if (' a ' <=c && c<= ' F ') {return (short (c ' a ') + 10); } else if (' A ' <=c && c<= ' F ') {return (short (c ' a ') + 10); } else {return-1; }} string Encodeurl (const string &url) {string strresult = ""; for (unsigned int i=0; i<url.size (); i++) {char c = url[i]; if (' 0 ' <=c && c<= ' 9 ') | | (' A ' <=c && c< = ' Z ') | | (' A ' <=c && c<= ' Z ') | | c== '/' | | c== '. ' ) {strresult + = C; } else {int j = (short int) C; if (J < 0) {j + = 256; } int i1, i0; I1 = J/16; I0 = j-i1*16; strresult + = '% '; Strresult + = Dec2hexchar (I1); Strresult + = Dec2hexchar (I0); }} return strresult; } std::string decodeurl (const std::string &url) {string result = ""; for (unsigned int i=0; i<url.size (); i++) {char c = url[i]; if (c! = '% ') {result + = C; } else {char C1 = url[++i]; char c0 = url[++i]; int num = 0; num + = HEXCHAR2DEC (C1) * + HEXCHAR2DEC (C0); Result + = char (num); }} return result; }
C + + URL Encode/decode (gb2312)