summaryrefslogtreecommitdiff
path: root/platform/default/codecvt
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2018-06-21 14:44:00 +0200
committerKonstantin Käfer <mail@kkaefer.com>2018-09-11 11:43:54 +0200
commit30e570aae7d2ba5522feafb962b334ef3f35459e (patch)
tree5a8f787197772ed302e1fbf45839d973feb80838 /platform/default/codecvt
parent536652ca201ce59190ae5c41d1202372d28d6d6d (diff)
downloadqtlocation-mapboxgl-30e570aae7d2ba5522feafb962b334ef3f35459e.tar.gz
[core] add polyfill for codecvt for STLs that don't have it yet
Diffstat (limited to 'platform/default/codecvt')
-rw-r--r--platform/default/codecvt/codecvt30
1 files changed, 30 insertions, 0 deletions
diff --git a/platform/default/codecvt/codecvt b/platform/default/codecvt/codecvt
new file mode 100644
index 0000000000..8d21e82348
--- /dev/null
+++ b/platform/default/codecvt/codecvt
@@ -0,0 +1,30 @@
+#pragma once
+
+// This is a minimal polyfill that'll only work exactly for how we use codecvt
+
+#include <string>
+#include <boost/locale/encoding_utf.hpp>
+
+namespace std {
+
+template <typename Codecvt, typename Elem = wchar_t>
+class wstring_convert {
+public:
+ static_assert(std::is_same<Elem, typename Codecvt::Elem>::value, "type mismatch");
+
+ inline std::basic_string<Elem> from_bytes(const string& str) {
+ return boost::locale::conv::utf_to_utf<Elem>(str);
+ }
+
+ inline string to_bytes(const std::basic_string<Elem>& str) {
+ return boost::locale::conv::utf_to_utf<char>(str);
+ }
+};
+
+template <typename E>
+class codecvt_utf8_utf16 {
+public:
+ using Elem = E;
+};
+
+} // namespace std