1 #include <samchon/library/Charset.hpp> 12 auto Charset::toMultibyte(
const string &source) ->
string 14 wstring &wstr = toUnicode(source, UTF8);
15 string &dest = toMultibyte(wstr);
20 auto Charset::toMultibyte(
const wstring &source) ->
string 22 int len = WideCharToMultiByte(CP_ACP, 0, &source[0], -1, NULL, 0, NULL, NULL);
23 std::string str(len, 0);
24 WideCharToMultiByte(CP_ACP, 0, &source[0], -1, &str[0], len, NULL, NULL);
55 auto Charset::toUTF8(
const string &source) ->
string 57 wstring &wstr = toUnicode(source, MULTIBYTE);
58 string &dest = toUTF8(wstr);
60 if (dest.back() == NULL)
66 auto Charset::toUTF8(
const wstring &source) ->
string 68 int len = WideCharToMultiByte(CP_UTF8, 0, &source[0], -1, NULL, 0, NULL, NULL);
69 std::string str(len, 0);
70 WideCharToMultiByte(CP_UTF8, 0, &source[0], -1, &str[0], len, NULL, NULL);
82 auto Charset::toUnicode(
const string &source,
int charset) -> wstring
84 if (charset == MULTIBYTE)
86 int nLen = MultiByteToWideChar(CP_ACP, 0, &source[0], (
int)source.size(), NULL, NULL);
87 std::wstring wstr(nLen, 0);
88 MultiByteToWideChar(CP_ACP, 0, &source[0], (
int)source.size(), &wstr[0], nLen);
114 else if (charset == UTF8)
116 int nLen = MultiByteToWideChar(CP_UTF8, 0, &source[0], (
int)source.size(), NULL, NULL);
117 std::wstring wstr(nLen, 0);
118 MultiByteToWideChar(CP_UTF8, 0, &source[0], (
int)source.size(), &wstr[0], nLen);