Support for Mapbox fontstack API
This commit is contained in:
29
src/util/url.cpp
Normal file
29
src/util/url.cpp
Normal 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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user