Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned char hs2i(char c)
- {
- if ('0' <= c && c <= '9') {
- return ((unsigned char)c - '0');
- } else if ('a' <= c && c <= 'f') {
- return ((unsigned char)c - 'a' + 10);
- } else if ('A' <= c && c <= 'F') {
- return ((unsigned char)c - 'A' + 10);
- } else {
- return 0;
- }
- }
- String decodeUri(String s) {
- String a = "";
- char c;
- std::pair<char, char> h;
- for (int i = 0; i < s.length(); i++) {
- c = s.charAt(i);
- if (c == '+') {
- a += ' ';
- } else if (c == '%') {
- h.first = s.charAt(++i);
- h.second = s.charAt(++i);
- c = (hs2i(h.first) << 4) | hs2i(h.second);
- a += c;
- } else {
- a += c;
- }
- yield();
- }
- return a;
- }
Add Comment
Please, Sign In to add comment