summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure38
-rw-r--r--gyp/mbgl-linux.gypi3
-rw-r--r--platform/default/string_stdlib.cpp55
3 files changed, 68 insertions, 28 deletions
diff --git a/configure b/configure
index afb94d4795..6894a7b275 100755
--- a/configure
+++ b/configure
@@ -37,21 +37,23 @@ alias mason='~/.mason/mason'
case $MASON_PLATFORM in
'ios')
- SQLITE_VERSION=system
- LIBPNG_VERSION=1.6.13
- LIBUV_VERSION=0.10.28
- ZLIB_VERSION=system
- BOOST_VERSION=system
- ;;
+ SQLITE_VERSION=system
+ LIBPNG_VERSION=1.6.13
+ LIBUV_VERSION=0.10.28
+ ZLIB_VERSION=system
+ BOOST_VERSION=system
+ NUNICODE_VERSION=1.4
+ ;;
*)
- GLFW_VERSION=a21f2377
- SQLITE_VERSION=system
- LIBPNG_VERSION=system
- LIBCURL_VERSION=system
- LIBUV_VERSION=0.10.28
- ZLIB_VERSION=system
- BOOST_VERSION=system
- ;;
+ GLFW_VERSION=a21f2377
+ SQLITE_VERSION=system
+ LIBPNG_VERSION=system
+ 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; }
@@ -138,6 +140,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 337e98039e..9f01ba3bb5 100644
--- a/gyp/mbgl-linux.gypi
+++ b/gyp/mbgl-linux.gypi
@@ -9,13 +9,16 @@
'cflags_cc': [
'<@(uv_cflags)',
'<@(curl_cflags)',
+ '<@(nu_cflags)',
],
'cflags': [
'<@(uv_cflags)',
+ '<@(nu_cflags)',
],
'ldflags': [
'<@(uv_ldflags)',
'<@(curl_ldflags)',
+ '<@(nu_ldflags)',
],
},
'sources': [
diff --git a/platform/default/string_stdlib.cpp b/platform/default/string_stdlib.cpp
index 1acbfa8508..d2c02e2881 100644
--- a/platform/default/string_stdlib.cpp
+++ b/platform/default/string_stdlib.cpp
@@ -1,24 +1,51 @@
#include <mbgl/platform/platform.hpp>
-
-#include <locale>
+#include <mbgl/util/utf.hpp>
+#define NU_WITH_TOUPPER
+#define NU_WITH_TOLOWER
+#define NU_WITH_UTF8_WRITER
+#include <libnu/libnu.h>
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::ctype<char>>(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<std::string::const_iterator> itr(str.begin());
+ boost::u8_to_u32_iterator<std::string::const_iterator> end(str.end());
+ std::string output;
+ char buf[4];
+ for (; itr!=end; ++itr)
+ {
+ char const* up = nu_toupper(*itr);
+ if (up != 0) output.append(up);
+ else
+ {
+ std::memset(buf, 0, 4);
+ 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::ctype<char>>(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<std::string::const_iterator> itr(str.begin());
+ boost::u8_to_u32_iterator<std::string::const_iterator> end(str.end());
+ std::string output;
+ char buf[4];
+ for (; itr!=end; ++itr)
+ {
+ char const* up = nu_tolower(*itr);
+ if (up != 0) output.append(up);
+ else
+ {
+ std::memset(buf, 0, 4);
+ nu_utf8_write(*itr, buf);
+ output.append(buf);
+ }
+ }
+ return output;
}
}