19 result.reserve(str.size() + str.size() / 16);
21 for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
25 case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
26 case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
27 case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
28 case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
29 case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
30 case 'h':
case 'i':
case 'j':
case 'k':
case 'l':
case 'm':
case 'n':
31 case 'o':
case 'p':
case 'q':
case 'r':
case 's':
case 't':
case 'u':
32 case 'v':
case 'w':
case 'x':
case 'y':
case 'z':
33 case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
34 case '7':
case '8':
case '9':
36 case '-':
case '_':
case '.':
case '~':
37 result.append(1, *it);
41 char first = (*it & 0xF0) / 16;
42 first += first > 9 ?
'A' - 10 :
'0';
43 char second = *it & 0x0F;
44 second += second > 9 ?
'A' - 10 :
'0';
46 result.append(1,
'%');
47 result.append(1, first);
48 result.append(1, second);
58 size_t slen = strlen(str);
60 result.reserve(slen + slen / 16);
62 for (
const char* it = str; *it != 0; ++it)
66 case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
67 case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
68 case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
69 case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
70 case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
71 case 'h':
case 'i':
case 'j':
case 'k':
case 'l':
case 'm':
case 'n':
72 case 'o':
case 'p':
case 'q':
case 'r':
case 's':
case 't':
case 'u':
73 case 'v':
case 'w':
case 'x':
case 'y':
case 'z':
74 case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
75 case '7':
case '8':
case '9':
77 case '-':
case '_':
case '.':
case '~':
78 result.append(1, *it);
82 char first = (*it & 0xF0) / 16;
83 first += first > 9 ?
'A' - 10 :
'0';
84 char second = *it & 0x0F;
85 second += second > 9 ?
'A' - 10 :
'0';
87 result.append(1,
'%');
88 result.append(1, first);
89 result.append(1, second);
std::string escape_uri(const std::string &str)
Escape a string into a URI-encoding.