Created
October 12, 2018 00:38
-
-
Save Akira-Hayasaka/e0a2d2da41c47acb4dbc5a991eb4b35b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto conv_utf8_to_sjis = [](string srcUTF8) -> string | |
{ | |
int lenghtUnicode = MultiByteToWideChar(CP_UTF8, 0, srcUTF8.c_str(), srcUTF8.size() + 1, NULL, 0); | |
wchar_t* bufUnicode = new wchar_t[lenghtUnicode]; | |
MultiByteToWideChar(CP_UTF8, 0, srcUTF8.c_str(), srcUTF8.size() + 1, bufUnicode, lenghtUnicode); | |
int lengthSJis = WideCharToMultiByte(CP_THREAD_ACP, 0, bufUnicode, -1, NULL, 0, NULL, NULL); | |
char* bufShiftJis = new char[lengthSJis]; | |
WideCharToMultiByte(CP_THREAD_ACP, 0, bufUnicode, lenghtUnicode + 1, bufShiftJis, lengthSJis, NULL, NULL); | |
string strSJis(bufShiftJis); | |
delete bufUnicode; | |
delete bufShiftJis; | |
return strSJis; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment