根据这个博文,有这些转义
http url转义字符,特殊字符 – yutingliuyl – 博客园
空格 – %20
” – %22
# – %23
% – %25
& – %26
( – %28
) – %29
+ – %2B
, – %2C
/ – %2F
: – %3A
; – %3B
< – %3C
= – %3D
> – %3E
?
– %3F
@ – %40
\ – %5C
| – %7C
根据ESP32的例程对转义处理函数如下
void preprocess_string(char* str)
{
char *p, *q;
for (p = q = str; *p != 0; p++)
{
if (*(p) == ‘%’ && *(p + 1) != 0 && *(p + 2) != 0)
{
// quoted hex
uint8_t a;
p++;//直接去掉%,处理第一个数字
if (*p <= ‘9’)
a = *p – ‘0’;
else
a = toupper((unsigned char)*p) – ‘A’ + 10;
a <<= 4;
p++;//第二个数字
if (*p <= ‘9’)
a += *p – ‘0’;
else
a += toupper((unsigned char)*p) – ‘A’ + 10;
*q++ = a;
}
else if (*(p) == ‘+’) {
*q++ = ‘ ‘;//空格
} else {
*q++ = *p;//不变
}
}
*q = ‘\0’;
}