26 #include "../url_encoding/url_encoding.h"
28 namespace ace_common {
30 uint8_t backslashXEncode(
char* t,
size_t tcap,
const char* s,
size_t* written) {
32 char*
const tend = t + tcap - 1;
46 if (tt >= tend)
break;
48 if (c >=
' ' && c < 127) {
51 if (tt >= tend)
break;
57 if (tt >= tend)
break;
62 byteToHexChar(c, &high, &low);
64 if (tt >= tend)
break;
67 if (tt >= tend)
break;
79 uint8_t backslashXDecode(
char* t,
size_t tcap,
const char* s,
size_t* written) {
81 char*
const tend = t + tcap - 1;
93 if (tt >= tend)
break;
99 if (escape ==
'\0')
break;
102 if (escape ==
'\\') {
105 if (escape !=
'x')
break;
109 if (high ==
'\0')
break;
113 if (low ==
'\0')
break;
116 c = (hexCharToByte(high) << 4) | hexCharToByte(low);
118 }
else if (c < ' ' || c >= 127) {
Provides 2 functions to perform backslash-x encoding and decoding.
bool isHexChar(char c)
Return true if 'c' is a hex character [0-9a-fA-F].