Better text printing for UTF-8 characters
authorSam Lantinga <slouken@libsdl.org>
Mon, 24 Jun 2013 22:06:50 -0700
changeset 731737b77749523b
parent 7316 c3052ed2c310
child 7318 46a5a6b8678e
Better text printing for UTF-8 characters
test/checkkeys.c
     1.1 --- a/test/checkkeys.c	Sun Jun 23 22:19:38 2013 -0700
     1.2 +++ b/test/checkkeys.c	Mon Jun 24 22:06:50 2013 -0700
     1.3 @@ -117,7 +117,15 @@
     1.4  static void
     1.5  PrintText(char *text)
     1.6  {
     1.7 -    SDL_Log("Text: %s\n", text);
     1.8 +    unsigned char *spot, expanded[1024];
     1.9 +
    1.10 +    expanded[0] = '\0';
    1.11 +    for ( spot = text; *spot; ++spot )
    1.12 +    {
    1.13 +        size_t length = SDL_strlen(expanded);
    1.14 +        SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", *spot);
    1.15 +    }
    1.16 +    SDL_Log("Text (%s): \"%s%s\"\n", expanded, *text == '"' ? "\\" : "", text);
    1.17  }
    1.18  
    1.19  int