textutils: encode to UTF-8 before sending to the application.
authorMatthew Mondor <mmondor@rpi.xisop>
Fri, 15 Apr 2022 18:58:22 +0000 (14:58 -0400)
committerMatthew Mondor <mmondor@rpi.xisop>
Fri, 15 Apr 2022 18:58:22 +0000 (14:58 -0400)
This allows to pass Latin-1, etc.  Dead accents support still
lacking.

utils/textclient.c

index d18edcc..8f4db2f 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <stdbool.h>
 #include "utils.h"
+#include "utf8wc.h"
 
 #if !defined(USE_IPHONE) && !defined(HAVE_ANDROID)  /* whole file */
 
@@ -911,8 +912,15 @@ send:
             c |= 0x80;
         }
 
-      fputc (c, d->pipe);
-      fflush (d->pipe);
+      /* Encode to unicode UTF-8 and send */
+      {
+             char utf[8];
+             int sz;
+
+             sz = utf8_encode(c, utf, 7);
+             (void)fwrite(utf, sz, 1, d->pipe);
+             (void)fflush(d->pipe);
+      }
       k->type = 0;  /* don't interpret this event defaultly. */
 
 # ifdef DEBUG