shithub: choc

Download patch

ref: 410c695fa1b7994934545cccc7cc6afc28e9db3b
parent: ce82099ff17328f1be9f37d14458866e06bb4fa3
author: Simon Howard <fraggle@soulsphere.org>
date: Fri Jan 20 21:12:44 EST 2017

setup: Print key names as UTF8.

Key names can contain arbitrary Unicode characters and these should
be printed to the screen using TXT_DrawUTF8String(). Noted as part
of #840 where random garbled characters were being shown for key
labels as a result of UTF8->Extended ASCII mojibake.

--- a/src/setup/txt_keyinput.c
+++ b/src/setup/txt_keyinput.c
@@ -22,6 +22,7 @@
 #include "txt_gui.h"
 #include "txt_io.h"
 #include "txt_label.h"
+#include "txt_utf8.h"
 #include "txt_window.h"
 
 #define KEY_INPUT_WIDTH 8
@@ -113,10 +114,10 @@
 
     TXT_SetWidgetBG(key_input);
     TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);
-    
-    TXT_DrawString(buf);
-    
-    for (i=strlen(buf); i<KEY_INPUT_WIDTH; ++i)
+
+    TXT_DrawUTF8String(buf);
+
+    for (i = TXT_UTF8_Strlen(buf); i < KEY_INPUT_WIDTH; ++i)
     {
         TXT_DrawString(" ");
     }