| 160 | } |
| 161 | |
| 162 | std::string unhex(const std::string& s) |
| 163 | { |
| 164 | std::stringstream sin(s); |
| 165 | std::stringstream sout; |
| 166 | |
| 167 | for (;;) |
| 168 | { |
| 169 | int c = sin.get(); |
| 170 | if (c == -1) |
| 171 | break; |
| 172 | if (c == '%') |
| 173 | { |
| 174 | char buf[3]; |
| 175 | buf[0] = sin.get(); |
| 176 | buf[1] = sin.get(); |
| 177 | buf[2] = 0; |
| 178 | |
| 179 | c = std::stoul(buf, nullptr, 16); |
| 180 | } |
| 181 | sout << (char)c; |
| 182 | } |
| 183 | |
| 184 | return sout.str(); |
| 185 | } |
| 186 | |
| 187 | std::string tohex(const std::string& s) |
| 188 | { |