MCPcopy Create free account
hub / github.com/apache/qpid-proton / pni_urlencode

Function pni_urlencode

cpp/src/url.cpp:37–53  ·  view source on GitHub ↗

URL-encode src and append to dst. */

Source from the content-addressed store, hash-verified

35
36/** URL-encode src and append to dst. */
37static std::string pni_urlencode(const std::string &src) {
38 static const char *bad = "@:/%[]?#";
39
40 std::ostringstream dst;
41 dst << std::hex << std::uppercase << std::setfill('0');
42
43 std::size_t i = 0;
44 std::size_t j = src.find_first_of(bad);
45 while (j!=std::string::npos) {
46 dst << src.substr(i, j-i);
47 dst << "%" << std::setw(2) << int(src[j]);
48 i = j + 1;
49 j = src.find_first_of(bad, i);
50 }
51 dst << src.substr(i);
52 return dst.str();
53}
54
55// Low level url parser
56static void pni_urldecode(const char *src, char *dst)

Callers 1

url::implClass · 0.70

Calls 2

substrMethod · 0.80
strMethod · 0.45

Tested by

no test coverage detected