| 306 | } |
| 307 | |
| 308 | std::string url_encode(const std::string& text) { |
| 309 | char hex[5]; |
| 310 | std::string destination; |
| 311 | for (size_t i = 0; i < text.size(); ++i) { |
| 312 | unsigned char c = text[i]; |
| 313 | if (isAlphanumeric(c)) { |
| 314 | destination += c; |
| 315 | } |
| 316 | else if (isWhitespace(c)) { |
| 317 | destination += '+'; |
| 318 | } |
| 319 | else { |
| 320 | destination += '%'; |
| 321 | sprintf(hex, "%-2.2X", c); |
| 322 | destination.append(hex); |
| 323 | } |
| 324 | } |
| 325 | return destination; |
| 326 | } |
| 327 | |
| 328 | |
| 329 | std::string escape(const std::string& text, char escaper) { |
no test coverage detected