Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Better text printing for UTF-8 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jun 25, 2013
1 parent 95014b7 commit 1a9b3ae
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/checkkeys.c
Expand Up @@ -117,7 +117,15 @@ PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat)
static void
PrintText(char *text)
{
SDL_Log("Text: %s\n", text);
unsigned char *spot, expanded[1024];

expanded[0] = '\0';
for ( spot = text; *spot; ++spot )
{
size_t length = SDL_strlen(expanded);
SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", *spot);
}
SDL_Log("Text (%s): \"%s%s\"\n", expanded, *text == '"' ? "\\" : "", text);
}

int
Expand Down

0 comments on commit 1a9b3ae

Please sign in to comment.