Fix String.http_escape on Windows
(cherry picked from commit 1a7e3b3ab6
)
This commit is contained in:
parent
4a83c2944c
commit
d52681085e
|
@ -3426,21 +3426,19 @@ String String::http_escape() const {
|
||||||
const CharString temp = utf8();
|
const CharString temp = utf8();
|
||||||
String res;
|
String res;
|
||||||
for (int i = 0; i < temp.length(); ++i) {
|
for (int i = 0; i < temp.length(); ++i) {
|
||||||
char ord = temp[i];
|
uint8_t ord = temp[i];
|
||||||
if (ord == '.' || ord == '-' || ord == '_' || ord == '~' ||
|
if (ord == '.' || ord == '-' || ord == '_' || ord == '~' ||
|
||||||
(ord >= 'a' && ord <= 'z') ||
|
(ord >= 'a' && ord <= 'z') ||
|
||||||
(ord >= 'A' && ord <= 'Z') ||
|
(ord >= 'A' && ord <= 'Z') ||
|
||||||
(ord >= '0' && ord <= '9')) {
|
(ord >= '0' && ord <= '9')) {
|
||||||
res += ord;
|
res += ord;
|
||||||
} else {
|
} else {
|
||||||
char h_Val[3];
|
char p[4] = { '%', 0, 0, 0 };
|
||||||
#if defined(__GNUC__) || defined(_MSC_VER)
|
static const char hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
||||||
snprintf(h_Val, 3, "%02hhX", ord);
|
|
||||||
#else
|
p[1] = hex[ord >> 4];
|
||||||
sprintf(h_Val, "%02hhX", ord);
|
p[2] = hex[ord & 0xF];
|
||||||
#endif
|
res += p;
|
||||||
res += "%";
|
|
||||||
res += h_Val;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|
Loading…
Reference in New Issue