Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string urlDecode(string text)
- {
- string escaped;
- for (auto i = text.begin(), nd = text.end(); i < nd; ++i)
- {
- auto c = ( *i );
- switch(c)
- {
- case '%':
- if (i[1] && i[2]) {
- char hs[]{ i[1], i[2] };
- escaped += static_cast<char>(strtol(hs, nullptr, 16));
- i += 2;
- }
- break;
- case '+':
- escaped += ' ';
- break;
- default:
- escaped += c;
- }
- }
- return escaped;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement