about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-05-06 01:09:10 +0100
committerJames Booth <boothj5@gmail.com>2013-05-06 01:09:10 +0100
commitcb85af800f0d859bdd6220737f1f42ac8d13da3c (patch)
tree9c920dcff9b8b35bc869c200d9aa802c8f2c7c18
parent78ff58cf770b19b5f1eaf760d168799a8a6473e5 (diff)
downloadprofani-tty-cb85af800f0d859bdd6220737f1f42ac8d13da3c.tar.gz
Unicode support for /duck output
-rw-r--r--src/ui/core.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/ui/core.c b/src/ui/core.c
index 8e38ebbb..c2feb019 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -771,16 +771,21 @@ ui_duck_result(const char * const result)
         wprintw(windows[win_index]->win, "Result : ");
         wattroff(windows[win_index]->win, COLOUR_THEM);
 
-        int i = 0;
-        while (i < strlen(result)) {
-            if (result[i] == '\n') {
+
+
+        glong offset = 0;
+        while (offset < g_utf8_strlen(result, -1)) {
+            gchar *ptr = g_utf8_offset_to_pointer(result, offset);
+            gunichar unichar = g_utf8_get_char(ptr);
+            if (unichar == '\n') {
                 wprintw(windows[win_index]->win, "\n");
                 win_print_time(windows[win_index], '-');
             } else {
-                waddch(windows[win_index]->win, result[i]);
+                gchar *string = g_ucs4_to_utf8(&unichar, 1, NULL, NULL, NULL);
+                wprintw(windows[win_index]->win, string);
             }
 
-            i++;
+            offset++;
         }
 
         wprintw(windows[win_index]->win, "\n");