Skip to content

Instantly share code, notes, and snippets.

@Joshua-Ashton
Created August 8, 2018 20:14
Show Gist options
  • Save Joshua-Ashton/f67378ae4019f8b7b97a088c2bcd908e to your computer and use it in GitHub Desktop.
Save Joshua-Ashton/f67378ae4019f8b7b97a088c2bcd908e to your computer and use it in GitHub Desktop.
utf32 to utf8 example
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