Created
October 24, 2018 07:27
-
-
Save RChehowski/6e4fcd2a2fc0c61e1ef19697f519a8ae 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
int utf8_to_wide_char(const char* UTF8_string, wchar_t** OUT_wide_chars, size_t* OUT_size) | |
{ | |
if (!UTF8_string) | |
return 1; | |
const size_t length = (size_t)MultiByteToWideChar(CP_UTF8, 0, UTF8_string, -1, NULL, 0); | |
wchar_t* wide_characters = (wchar_t*)malloc(length * sizeof(wchar_t)); | |
if (!wide_characters) | |
{ | |
return 1; | |
} | |
if (length > 0) | |
{ | |
MultiByteToWideChar(CP_UTF8, 0, UTF8_string, -1, wide_characters, length); | |
} | |
if (OUT_wide_chars) | |
*OUT_wide_chars = wide_characters; | |
if (OUT_size) | |
*OUT_size = length; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment