Irssi: Input line is echoing utf8 chars on non-utf8 terminal

Created on 20 Feb 2019  路  6Comments  路  Source: irssi/irssi

I have a legacy Linux installation that still uses ISO-8859-1 charset. Commit 9072e988194a36186bd98db844b8285e3f37069a causes irssi to erroneously echo utf8 chars to the input line (start irssi, press '盲' key, irssi outputs '脙陇' on the input line, cursor is placed between the two chars) instead of ISO-8859-1. Everything else seems to work fine, with no encoding problems when sending/receiving text from/to IRC channels. Only input line is affected.

WIP bug z-affects-1.2.0

Most helpful comment

diff -ru irssi-1.2.0/src/fe-text/gui-entry.c irssi-1.2.0_patched/src/fe-text/gui-entry.c
--- irssi-1.2.0/src/fe-text/gui-entry.c 2019-02-11 20:27:58.000000000 +0300
+++ irssi-1.2.0_patched/src/fe-text/gui-entry.c 2019-02-19 17:48:00.468255567 +0300
@@ -381,8 +381,12 @@

                if (entry->hidden)
                         g_string_append_c(str, ' ');
-               else if (unichar_isprint(c))
-                       g_string_append_unichar(str, c);
+               else if (unichar_isprint(c)) {
+                       if (entry->utf8)
+                               g_string_append_unichar(str, c);
+                       else
+                               g_string_append_c(str, c);
+               }
                else {
                        g_string_append_c(str, 4);
                        g_string_append_c(str, FORMAT_STYLE_REVERSE);

All 6 comments

Relevant: #671

diff -ru irssi-1.2.0/src/fe-text/gui-entry.c irssi-1.2.0_patched/src/fe-text/gui-entry.c
--- irssi-1.2.0/src/fe-text/gui-entry.c 2019-02-11 20:27:58.000000000 +0300
+++ irssi-1.2.0_patched/src/fe-text/gui-entry.c 2019-02-19 17:48:00.468255567 +0300
@@ -381,8 +381,12 @@

                if (entry->hidden)
                         g_string_append_c(str, ' ');
-               else if (unichar_isprint(c))
-                       g_string_append_unichar(str, c);
+               else if (unichar_isprint(c)) {
+                       if (entry->utf8)
+                               g_string_append_unichar(str, c);
+                       else
+                               g_string_append_c(str, c);
+               }
                else {
                        g_string_append_c(str, 4);
                        g_string_append_c(str, FORMAT_STYLE_REVERSE);

Thank you @saahriktu, that patch seems to fix the charset problem.

nice catch. I am wondering if this fixes/breaks Big5 terminals

Do we know if this patch has any adverse effects on on those terminals or anything else yet? It was requested that this patch be added to the FreeBSD port, but I'm unsure since I can't easily test it myself.

@pyksy @saahriktu can you verify if I didn't screw up in #1057

Was this page helpful?
0 / 5 - 0 ratings