优化url编解码

This commit is contained in:
xiongziliang 2020-03-12 18:19:22 +08:00
parent 119d90bc58
commit a6928a0bfe
1 changed files with 4 additions and 4 deletions

View File

@ -76,9 +76,9 @@ string strCoding::UrlEncode(const string &str) {
if (isalnum((uint8_t)ch)) { if (isalnum((uint8_t)ch)) {
out.push_back(ch); out.push_back(ch);
}else { }else {
char tempbuff[4]; char buf[4];
sprintf(tempbuff, "%%%X%X", (uint8_t)str[i] >> 4,(uint8_t)str[i] % 16); sprintf(buf, "%%%X%X", (uint8_t)ch >> 4,(uint8_t)ch & 0x0F);
out.append(tempbuff); out.append(buf);
} }
} }
return out; return out;