Better text printing for UTF-8 characters
authorSam Lantinga <slouken@libsdl.org>
Mon, 24 Jun 2013 22:06:50 -0700
changeset 7317 37b77749523b
parent 7316 c3052ed2c310
child 7318 46a5a6b8678e
Better text printing for UTF-8 characters
test/checkkeys.c
--- a/test/checkkeys.c	Sun Jun 23 22:19:38 2013 -0700
+++ b/test/checkkeys.c	Mon Jun 24 22:06:50 2013 -0700
@@ -117,7 +117,15 @@
 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