| 47 | } |
| 48 | |
| 49 | std::string url_decode(std::string str) { |
| 50 | std::string ret; |
| 51 | char ch; |
| 52 | size_t len = str.length(); |
| 53 | |
| 54 | for (unsigned int i = 0; i < len; i++) { |
| 55 | unsigned int ii; |
| 56 | if (str[i] != '%') { |
| 57 | if (str[i] == '+') { |
| 58 | ret += ' '; |
| 59 | } else { |
| 60 | ret += str[i]; |
| 61 | } |
| 62 | } else { |
| 63 | sscanf(str.substr(i + 1, 2).c_str(), "%x", &ii); |
| 64 | ch = static_cast<char>(ii); |
| 65 | ret += ch; |
| 66 | i = i + 2; |
| 67 | } |
| 68 | } |
| 69 | return ret; |
| 70 | } |
| 71 | |
| 72 | #ifdef GTEST |
| 73 | #include "gtest/gtest.h" |
no outgoing calls
no test coverage detected