MCPcopy Create free account
hub / github.com/davisking/dlib / urldecode

Function urldecode

dlib/server/server_http.cpp:60–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58 }
59
60 const std::string urldecode (
61 const std::string& str
62 )
63 {
64 using namespace std;
65 string result;
66 string::size_type i;
67 for (i = 0; i < str.size(); ++i)
68 {
69 if (str[i] == '+')
70 {
71 result += ' ';
72 }
73 else if (str[i] == '%' && str.size() > i+2)
74 {
75 const unsigned char ch1 = from_hex(str[i+1]);
76 const unsigned char ch2 = from_hex(str[i+2]);
77 const unsigned char ch = (ch1 << 4) | ch2;
78 result += ch;
79 i += 2;
80 }
81 else
82 {
83 result += str[i];
84 }
85 }
86 return result;
87 }
88
89 void parse_url(
90 std::string word,

Callers 3

grab_urlMethod · 0.85
parse_urlFunction · 0.85
parse_http_requestFunction · 0.85

Calls 2

from_hexFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected