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

Function urlencode

dlib/server/server_http.cpp:20–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18 }
19
20 const std::string urlencode( const std::string& s )
21 {
22 std::ostringstream os;
23
24 for ( std::string::const_iterator ci = s.begin(); ci != s.end(); ++ci )
25 {
26 if ( (*ci >= 'a' && *ci <= 'z') ||
27 (*ci >= 'A' && *ci <= 'Z') ||
28 (*ci >= '0' && *ci <= '9') )
29 { // allowed
30 os << *ci;
31 }
32 else if ( *ci == ' ')
33 {
34 os << '+';
35 }
36 else
37 {
38 os << '%' << to_hex(*ci >> 4) << to_hex(*ci % 16);
39 }
40 }
41
42 return os.str();
43 }
44
45 inline unsigned char from_hex (
46 unsigned char ch

Callers 3

build_postMethod · 0.85
grab_urlMethod · 0.85
write_http_responseFunction · 0.85

Calls 4

to_hexFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected