From a6928a0bfee06d4bba05d4938ccbe08f1f99cd5a Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 12 Mar 2020 18:19:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96url=E7=BC=96=E8=A7=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/strCoding.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Http/strCoding.cpp b/src/Http/strCoding.cpp index 58dab0c5..2a01f73e 100644 --- a/src/Http/strCoding.cpp +++ b/src/Http/strCoding.cpp @@ -71,14 +71,14 @@ char StrToBin(const char *str) string strCoding::UrlEncode(const string &str) { string out; size_t len = str.size(); - for (size_t i = 0; i < len; ++i) { + for (size_t i = 0; i < len; ++i) { char ch = str[i]; if (isalnum((uint8_t)ch)) { out.push_back(ch); }else { - char tempbuff[4]; - sprintf(tempbuff, "%%%X%X", (uint8_t)str[i] >> 4,(uint8_t)str[i] % 16); - out.append(tempbuff); + char buf[4]; + sprintf(buf, "%%%X%X", (uint8_t)ch >> 4,(uint8_t)ch & 0x0F); + out.append(buf); } } return out;