[PATCH] utf8 input in tty.c
Magnus Damm <[email protected]>
| Newsgroups | gmane.editors.qemacs.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello there, This patch makes it possible to input multibyte utf-8 chars correctly using a tty. Without the patch multibyte chars (like the swedish chars "å", "ä" and "ö") would end up as two "?"- chars each... Thanks! / magnus - not subscribed, please cc _______________________________________________ Qemacs-devel mailing list [email protected] http://mail.nongnu.org/mailman/listinfo/qemacs-devel
qemacs-0.3.1-tty_utf8.patch
(application/octet-stream, 952 B)
--- qemacs-0.3.1/tty.c 2003-04-22 00:01:42.000000000 +0200
+++ qemacs-0.3.1-tty_utf8/tty.c 2004-03-14 17:38:58.000000000 +0100
@@ -53,7 +53,6 @@
/* input handling */
enum InputState input_state;
int input_param;
- int utf8_state;
int utf8_index;
unsigned char buf[10];
} TTYState;
@@ -211,15 +210,20 @@
/* charset handling */
if (s->charset == &charset_utf8) {
- if (ts->utf8_state == 0) {
+
+ /* Make sure utf8 input works correctly 20040314 <[email protected]> */
+
+ ts->utf8_index++;
+
+ if (utf8_length[ts->buf[0]] == ts->utf8_index) {;
const char *p;
p = ts->buf;
ch = utf8_decode(&p);
- } else {
- ts->utf8_state = utf8_length[ts->buf[0]] - 1;
- ts->utf8_index = 0;
- return;
- }
+ ts->utf8_index = 0;
+ }
+ else {
+ return;
+ }
} else {
ch = ts->buf[0];
}