Package: ircii
Version: 20051015-2
Severity: wishlist

When irc_encoding is utf-8 and the current locale is latin1 and someone
sends latin1-characters, they are silently omitted.

It would be nice if there was some way to specify either a fallback
or at least replace them with question marks or something like that.

Attached patch hard-coded assumes every bytes iconv could not handle are
encoded in latin1 and converts accordingly. Making that configurable
(something like /set irc_encoding utf-8:latin1) would be nice, but more
complex to code.

Hochachtungsvoll,
        Bernhard R. Link
diff -r -u ircii-20051015.old/source/translat.c ircii-20051015/source/translat.c
--- ircii-20051015.old/source/translat.c        2005-09-22 20:20:04.000000000 
+0200
+++ ircii-20051015/source/translat.c    2006-12-01 18:31:09.429090026 +0100
@@ -619,13 +619,24 @@
                                        ++ptr;
                                        goto endloop;
                                case EILSEQ:
-                                       /* Ignore invalid byte, continue loop. 
*/
-                                       error = 1;
+                                       /* try to decode as latin1 */
                                        if (*ptr != '\0')
                                        {
-                                               ++ptr;
+                                               unsigned unival = *ptr;
                                                ++data->input_bytes;
+
+                                               if (unival >= 0x80 && unival < 
0x800) {
+                                                       ++ptr;
+                                                       data->output_bytes += 2;
+                                                       *(utfptr++) = 
(u_char)(0xC0 + (unival>>6));
+                                                       *(utfptr++) = 
(u_char)(0x80 + (unival&63));
+                                                       *utfptr = '\0';
+                                                       goto endloop;
+                                               }
+                                               ++ptr;
                                        }
+                                       /* Ignore invalid byte, continue loop. 
*/
+                                       error = 1;
                                        continue;
                                }
                        }

Reply via email to