lime
Lime is a C++ library implementing Open Whisper System Signal protocol
string_conversion.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 // If you want to supply your own UTF-8 <-> UTF-16 conversion routines, create a header file
4 // that can be found at <jni/string_conversion.hpp> and will be found first in the lookup chain.
5 
6 #include <string>
7 #include <locale>
8 #include <codecvt>
9 
10 namespace jni
11  {
12  inline std::u16string convertUTF8ToUTF16(const std::string& string)
13  {
14  return std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().from_bytes(string);
15  }
16 
17  inline std::string convertUTF16ToUTF8(const std::u16string& string)
18  {
19  return std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>().to_bytes(string);
20  }
21  }
std::string convertUTF16ToUTF8(const std::u16string &string)
Definition: string_conversion.hpp:17
std::u16string convertUTF8ToUTF16(const std::string &string)
Definition: string_conversion.hpp:12
Definition: advanced_ownership.hpp:5