summaryrefslogtreecommitdiff
path: root/platform/qt/src/utf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/qt/src/utf.cpp')
-rw-r--r--platform/qt/src/utf.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/platform/qt/src/utf.cpp b/platform/qt/src/utf.cpp
new file mode 100644
index 0000000000..d8bf2ca0b3
--- /dev/null
+++ b/platform/qt/src/utf.cpp
@@ -0,0 +1,17 @@
+#include <mbgl/util/utf.hpp>
+
+#include <QString>
+
+namespace mbgl {
+namespace util {
+
+std::u16string utf8_to_utf16::convert(std::string const& utf8) {
+ auto utf16 = QString::fromUtf8(utf8.data(), utf8.length());
+
+ // Newers Qt have QString::toStdU16String(), but this is how it is
+ // implemented. Do it here to keep compatibility with older versions.
+ return std::u16string(reinterpret_cast<const char16_t*>(utf16.utf16()), utf16.length());
+}
+
+} // namespace util
+} // namespace mbgl