[core] unify UTF-8/16 conversion to <boost/locale/encoding_utf.hpp>
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
#include <mbgl/util/utf.hpp>
|
||||
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
#include <boost/locale/encoding_utf.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
std::u16string utf8_to_utf16::convert(const std::string& utf8) {
|
||||
return std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().from_bytes(utf8);
|
||||
std::u16string convertUTF8ToUTF16(const std::string& str) {
|
||||
return boost::locale::conv::utf_to_utf<char16_t>(str);
|
||||
}
|
||||
|
||||
std::string convertUTF16ToUTF8(const std::u16string& str) {
|
||||
return boost::locale::conv::utf_to_utf<char>(str);
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
|
||||
Reference in New Issue
Block a user