Created
August 8, 2018 20:14
-
-
Save misyltoad/f67378ae4019f8b7b97a088c2bcd908e to your computer and use it in GitHub Desktop.
utf32 to utf8 example
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
char LocalMessageText[281] = ""; | |
u16 LocalMessageLength = 0; | |
void RenderKeyCallback(unsigned int codepoint) | |
{ | |
std::mbstate_t state{}; | |
char utf8[16]; | |
memset(utf8, 0, 16); | |
u16 size = c32rtomb(utf8, codepoint, &state); | |
if (LocalMessageLength + size < 281) | |
{ | |
LocalMessageLength += size; | |
strcat(LocalMessageText, utf8); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment