diff --git a/platform/qt/platform.gyp b/platform/qt/platform.gyp index 880e36653..b948898e2 100644 --- a/platform/qt/platform.gyp +++ b/platform/qt/platform.gyp @@ -46,7 +46,6 @@ '../default/mbgl/storage/offline_download.cpp', '../default/online_file_source.cpp', '../default/sqlite3.cpp', - '../default/string_stdlib.cpp', 'include/qmapbox.hpp', 'include/qmapboxgl.hpp', 'include/qquickmapboxgl.hpp', @@ -66,6 +65,7 @@ 'src/qquickmapboxglrenderer.hpp', 'src/run_loop.cpp', 'src/run_loop_impl.hpp', + 'src/string_stdlib.cpp', 'src/timer.cpp', 'src/timer_impl.hpp', ], diff --git a/platform/qt/scripts/configure.sh b/platform/qt/scripts/configure.sh index 42541032c..be809708b 100644 --- a/platform/qt/scripts/configure.sh +++ b/platform/qt/scripts/configure.sh @@ -10,7 +10,6 @@ GEOJSON_VERSION=0.1.4${CXX11ABI:-} GEOJSONVT_VERSION=6.1.0 GTEST_VERSION=1.7.0${CXX11ABI:-} LIBJPEG_TURBO_VERSION=1.4.2 -NUNICODE_VERSION=1.6 PIXELMATCH_VERSION=0.9.0 RAPIDJSON_VERSION=1.0.2 SQLITE_VERSION=3.9.1 @@ -20,12 +19,15 @@ WEBP_VERSION=0.5.0 EARCUT_VERSION=0.11 function print_default_flags { - CONFIG+=" 'cflags': $(quote_flags -fvisibility=hidden),"$LN + CONFIG+=" 'cflags': $(quote_flags -fvisibility=hidden -D__QT__),"$LN } if [ "$MASON_PLATFORM" == "osx" ]; then + # XXX: Argh, adding the __QT__ flag here because GYP for OSX does + # not respect the `cflags` variable above and we need it to reach + # the utests somehow. Gonna be fixed properly when we move to CMake. function print_opengl_flags { - CONFIG+=" 'opengl_cflags%': [],"$LN + CONFIG+=" 'opengl_cflags%': ['-D__QT__'],"$LN CONFIG+=" 'opengl_ldflags%': ['-framework OpenGL', '-framework CoreFoundation'],"$LN } else diff --git a/platform/qt/src/string_stdlib.cpp b/platform/qt/src/string_stdlib.cpp new file mode 100644 index 000000000..c4adecea0 --- /dev/null +++ b/platform/qt/src/string_stdlib.cpp @@ -0,0 +1,24 @@ +#include + +#include +#include + +#include + +namespace mbgl { +namespace platform { + +std::string uppercase(const std::string& str) { + auto upper = QString::fromUtf8(str.c_str()).toUpper().toUtf8(); + + return std::string(upper.constData(), upper.size()); +} + +std::string lowercase(const std::string& str) { + auto lower = QString::fromUtf8(str.c_str()).toLower().toUtf8(); + + return std::string(lower.constData(), lower.size()); +} + +} // namespace platform +} // namespace mbgl diff --git a/test/util/text_conversions.cpp b/test/util/text_conversions.cpp index 506453785..19e30d9f3 100644 --- a/test/util/text_conversions.cpp +++ b/test/util/text_conversions.cpp @@ -16,7 +16,6 @@ TEST(TextConversions, to_upper) { EXPECT_EQ(std::string("BÊNÇÃO"), platform::uppercase("bênção")); // PT EXPECT_EQ(std::string("AZƏRBAYCAN"), platform::uppercase("Azərbaycan")); // AZ - EXPECT_EQ(std::string("ὈΔΥΣΣΕΎΣ"), platform::uppercase("Ὀδυσσεύς")); // GR } @@ -32,6 +31,12 @@ TEST(TextConversions, to_lower) { EXPECT_EQ(std::string("bênção"), platform::lowercase("BÊNÇÃO")); // PT EXPECT_EQ(std::string("azərbaycan"), platform::lowercase("AZƏRBAYCAN")); // AZ + +#if defined(__QT__) + // https://bugreports.qt.io/browse/QTBUG-17337 + EXPECT_NE(std::string("ὀδυσσεύς"), platform::lowercase("ὈΔΥΣΣΕΎΣ")); // GR +#else EXPECT_EQ(std::string("ὀδυσσεύς"), platform::lowercase("ὈΔΥΣΣΕΎΣ")); // GR +#endif }