Btk
codecvt.hpp
1 #if !defined(_BTKIMPL_CODECVT_HPP_)
2 #define _BTKIMPL_CODECVT_HPP_
3 #include <SDL2/SDL_stdinc.h>
4 #include <string>
5 #include <string_view>
6 #include "../exception.hpp"
7 namespace Btk{
8  inline std::u16string Utf8ToUtf16(std::string_view utf8){
9  char *str = SDL_iconv_string("UTF16","UTF8",utf8.data(),utf8.size());
10  if(str == nullptr){
11  throwSDLError();
12  }
13  std::u16string utf16(reinterpret_cast<char16_t*>(str));
14  SDL_free(str);
15  return utf16;
16  }
17 };
18 #endif // _BTKIMPL_CODECVT_HPP_
This header include many useful containers.
Definition: async.hpp:7
Definition: checked.h:34