MCPcopy Create free account
hub / github.com/Exiv2/exiv2 / urlencode

Function urlencode

src/futils.cpp:98–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98std::string urlencode(const std::string& str) {
99 std::string encoded;
100 encoded.reserve(str.size() * 3);
101 for (uint8_t c : str) {
102 if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~')
103 encoded += c;
104 else if (c == ' ')
105 encoded += '+';
106 else {
107 encoded += '%';
108 encoded += to_hex(c >> 4);
109 encoded += to_hex(c & 15);
110 }
111 }
112 encoded.shrink_to_fit();
113 return encoded;
114}
115
116void urldecode(std::string& str) {
117 size_t idxIn{0};

Callers 2

TESTFunction · 0.85
writeRemoteMethod · 0.85

Calls 3

to_hexFunction · 0.85
reserveMethod · 0.80
sizeMethod · 0.45

Tested by 1

TESTFunction · 0.68