MCPcopy Create free account
hub / github.com/cinder/Cinder / urlencode

Function urlencode

src/cinder/Url.cpp:67–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67std::string urlencode( const std::string &c )
68{
69 std::string escaped;
70 int max = c.length();
71 for( int i = 0; i < max; ++i ) {
72 if( (48 <= c[i] && c[i] <= 57 ) || //0-9
73 (65 <= c[i] && c[i] <= 90 ) || //ABC...XYZ
74 (97 <= c[i] && c[i] <= 122) || //abc...xyz
75 (c[i]=='~' || c[i]=='-' || c[i]=='_' || c[i]=='.')
76 )
77 {
78std::cout << "Appending: " << std::string( &c[i], 1 ) << std::endl;
79 escaped.append( &c[i], 1 );
80 }
81 else
82 {
83 escaped.append( "%" );
84 escaped.append( char2hex( c[i] ) ); //converts char 255 to string "FF"
85 }
86 }
87 return escaped;
88}
89#endif
90
91

Callers 1

encodeMethod · 0.85

Calls 4

stringFunction · 0.85
char2hexFunction · 0.85
lengthMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected