Exemple #1
0
std::string UTF16ToUTF8(const std::u16string& input)
{
#if _MSC_VER >= 1900
    // Workaround for missing char16_t/char32_t instantiations in MSVC2015
    std::wstring_convert<std::codecvt_utf8_utf16<__int16>, __int16> convert;
    std::basic_string<__int16> tmp_buffer(input.cbegin(), input.cend());
    return convert.to_bytes(tmp_buffer);
#else
    std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
    return convert.to_bytes(input);
#endif
}
Exemple #2
0
Value::
Value(const std::u16string&  s):
type(ConstCharType().make_array(s.size()+1)),
base_address(0),
size(sizeof(char16_t)*(s.size()+1))
{
  data = new uint8_t[size];

  auto  dst = reinterpret_cast<char16_t*>(data);
  auto  src = s.cbegin();

    while(*src)
    {
      *dst++ = *src++;
    }


  dst = 0;
}