fix basepath for headless stylesheets

This commit is contained in:
Konstantin Käfer
2014-08-27 14:28:56 +02:00
parent a55be0217b
commit 953e5524a9
5 changed files with 61 additions and 57 deletions

View File

@@ -4,6 +4,7 @@
#include <iomanip>
#include <sstream>
#include <string>
#include <cstdlib>
namespace mbgl {
namespace util {
@@ -25,5 +26,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;
}
}
}