diff --git a/configure b/configure index 0113ee294..d23d53909 100755 --- a/configure +++ b/configure @@ -29,16 +29,18 @@ case ${MASON_PLATFORM} in LIBUV_VERSION=0.11.29 ZLIB_VERSION=system BOOST_VERSION=system + NUNICODE_VERSION=1.4 ;; *) - GLFW_VERSION=a21f2377 - SQLITE_VERSION=system - LIBPNG_VERSION=1.6.13 - LIBCURL_VERSION=system - LIBUV_VERSION=0.10.28 - ZLIB_VERSION=system - BOOST_VERSION=system - ;; + GLFW_VERSION=a21f2377 + SQLITE_VERSION=system + LIBPNG_VERSION=1.6.13 + LIBCURL_VERSION=system + LIBUV_VERSION=0.10.28 + ZLIB_VERSION=system + BOOST_VERSION=system + NUNICODE_VERSION=1.4 + ;; esac function abort { >&2 echo -e "\033[1m\033[31m$1\033[0m"; exit 1; } @@ -117,6 +119,14 @@ if [ ! -z ${ZLIB_VERSION} ]; then CONFIG+=" 'zlib_ldflags': $(quote_flags $(mason ldflags zlib ${ZLIB_VERSION})),"$LN fi +if [ ! -z ${NUNICODE_VERSION} ]; then + mason install nunicode ${NUNICODE_VERSION} + CONFIG+=" 'nu_static_libs': $(quote_flags $(mason static_libs nunicode ${NUNICODE_VERSION})),"$LN + CONFIG+=" 'nu_cflags': $(quote_flags $(mason cflags nunicode ${NUNICODE_VERSION})),"$LN + CONFIG+=" 'nu_ldflags': $(quote_flags $(mason ldflags nunicode ${NUNICODE_VERSION})),"$LN +fi + + CONFIG+=" } } " diff --git a/gyp/mbgl-linux.gypi b/gyp/mbgl-linux.gypi index ca3e2afc5..a22bd8f7c 100644 --- a/gyp/mbgl-linux.gypi +++ b/gyp/mbgl-linux.gypi @@ -10,14 +10,17 @@ '<@(png_cflags)', '<@(uv_cflags)', '<@(curl_cflags)', + '<@(nu_cflags)', ], 'cflags': [ '<@(uv_cflags)', + '<@(nu_cflags)', ], 'ldflags': [ '<@(png_ldflags)', '<@(uv_ldflags)', '<@(curl_ldflags)', + '<@(nu_ldflags)', ], }, 'sources': [ diff --git a/include/mbgl/util/utf.hpp b/include/mbgl/util/utf.hpp index ddf0ff306..d36cfae7e 100644 --- a/include/mbgl/util/utf.hpp +++ b/include/mbgl/util/utf.hpp @@ -3,25 +3,12 @@ #include -// g++/libstdc++ is missing c++11 codecvt support -#if 1//! defined(__clang__) || defined(__linux__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-local-typedefs" -//#include #include -#pragma GCC diagnostic pop -#else -// Assume that codecvt is present on clang on non-linux systems -#include -#include -#endif namespace mbgl { namespace util { -#if 1 //! defined(__clang__) || defined(__linux__) - class utf8_to_utf32 { public: explicit utf8_to_utf32() {} @@ -33,21 +20,6 @@ class utf8_to_utf32 { } }; -#else - -class utf8_to_utf32 { - public: - explicit utf8_to_utf32() - : utf32conv_() {} - std::u32string convert(std::string const& utf8) { - return utf32conv_.from_bytes(utf8); - } - private: - std::wstring_convert, char32_t> utf32conv_; -}; - -#endif - }} #endif diff --git a/linux/main.cpp b/linux/main.cpp index 7b96a349e..10d5d4582 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) { } // Load style - const std::string style = std::string("file://") + uv::cwd() + std::string("/styles/styles/bright-v5.json"); + const std::string style = std::string("file://") + uv::cwd() + std::string("/../../styles/styles/bright-v5.json"); map.setStyleURL(style); int ret = view->run(); diff --git a/platform/default/string_stdlib.cpp b/platform/default/string_stdlib.cpp index 1acbfa850..9639cd7b9 100644 --- a/platform/default/string_stdlib.cpp +++ b/platform/default/string_stdlib.cpp @@ -1,24 +1,52 @@ #include - -#include +#include +#define NU_WITH_TOUPPER +#define NU_WITH_TOLOWER +#define NU_WITH_UTF8_WRITER +#include +#include namespace mbgl { namespace platform { -std::string uppercase(const std::string& string) { - // TODO: Use a proper Unicode Special Casing-aware algorithm. - const auto &convert = std::use_facet>(std::locale()); - std::string converted = string; - convert.toupper(&converted[0], &converted[0] + converted.size()); - return converted; +std::string uppercase(const std::string& str) +{ + boost::u8_to_u32_iterator itr(str.begin()); + boost::u8_to_u32_iterator end(str.end()); + std::string output; + char buf[5]; + for (; itr!=end; ++itr) + { + char const* up = nu_toupper(*itr); + if (up != 0) output.append(up); + else + { + std::memset(buf, 0, 5); + nu_utf8_write(*itr, buf); + output.append(buf); + } + } + return output; } -std::string lowercase(const std::string& string) { - // TODO: Use a proper Unicode Special Casing-aware algorithm. - const auto &convert = std::use_facet>(std::locale()); - std::string converted = string; - convert.tolower(&converted[0], &converted[0] + converted.size()); - return converted; +std::string lowercase(const std::string& str) +{ + boost::u8_to_u32_iterator itr(str.begin()); + boost::u8_to_u32_iterator end(str.end()); + std::string output; + char buf[5]; + for (; itr!=end; ++itr) + { + char const* lo = nu_tolower(*itr); + if (lo != 0) output.append(lo); + else + { + std::memset(buf, 0, 5); + nu_utf8_write(*itr, buf); + output.append(buf); + } + } + return output; } }