28 namespace ace_common {
30 void formUrlEncode(Print& output,
const char* str) {
37 }
else if (isalnum(c)) {
42 byteToHexChar(c, &code0, &code1);
52 void formUrlDecode(Print& output,
const char* str) {
60 }
else if (c ==
'%') {
64 if (code0 ==
'\0')
break;
68 if (code1 ==
'\0')
break;
70 c = (hexCharToByte(code0) << 4) | hexCharToByte(code1);
76 void byteToHexChar(uint8_t c,
char* high,
char* low,
char baseChar) {
77 char lowNibble = (c & 0xf);
78 char highNibble = (c >> 4) & 0xf;
79 *low = (lowNibble > 9) ? lowNibble - 10 + baseChar : lowNibble +
'0';
80 *high = (highNibble > 9) ? highNibble - 10 + baseChar : highNibble +
'0';
83 uint8_t hexCharToByte(
char c) {
84 if (c >=
'0' && c <=
'9') {
90 if (c >=
'A' && c <=
'F') {
93 if (c >=
'a' && c <=
'f') {
Provides 2 functions to perform URL form encoding and decoding.