Merge branch 'master' into libuv010

This commit is contained in:
Mike Morris
2014-08-27 14:41:30 -04:00
18 changed files with 97 additions and 88 deletions

View File

@@ -4,6 +4,8 @@
#include <iomanip>
#include <sstream>
#include <string>
#include <cstdlib>
#include <algorithm>
namespace mbgl {
namespace util {
@@ -25,5 +27,25 @@ std::string percentEncode(const std::string& input) {
return encoded.str();
}
std::string percentDecode(const std::string& input) {
std::string decoded;
auto it = input.begin();
const auto end = input.end();
char hex[3] = "00";
while (it != end) {
auto cur = std::find(it, end, '%');
decoded.append(it, cur);
it = cur;
if (cur != end) {
it += input.copy(hex, 2, cur - input.begin() + 1) + 1;
decoded += static_cast<char>(std::strtoul(hex, nullptr, 16));
}
}
return decoded;
}
}
}