[core] GCC 4.9 does not provide <codecvt>

This commit is contained in:
Bruno de Oliveira Abinader
2017-07-11 17:42:50 +03:00
parent 3afbfa2de7
commit d918f8d7c2

View File

@@ -2,14 +2,24 @@
#include <memory>
#include <locale>
// GCC 4.9 compatibility
#if !defined(__GNUC__) || __GNUC__ >= 5
#include <codecvt>
#else
#include <boost/locale/encoding_utf.hpp>
#endif
namespace mbgl {
namespace util {
std::u16string utf8_to_utf16::convert(std::string const& utf8) {
#if !defined(__GNUC__) || __GNUC__ >= 5
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> converter;
return converter.from_bytes(utf8);
#else
return boost::locale::conv::utf_to_utf<char16_t>(utf8.c_str(), utf8.c_str() + utf8.size());
#endif
}
} // namespace util