Support for Mapbox fontstack API

This commit is contained in:
John Firebaugh
2014-08-22 15:31:57 -07:00
parent 3b43c4ddf2
commit 3d9a293258
9 changed files with 112 additions and 23 deletions

29
src/util/url.cpp Normal file
View File

@@ -0,0 +1,29 @@
#include <mbgl/util/url.hpp>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <string>
namespace mbgl {
namespace util {
std::string percentEncode(const std::string& input) {
std::ostringstream encoded;
encoded.fill('0');
encoded << std::hex;
for (auto c : input) {
if (std::isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') {
encoded << c;
} else {
encoded << '%' << std::setw(2) << int(c);
}
}
return encoded.str();
}
}
}