diff options
Diffstat (limited to 'src/utf8.c')
-rw-r--r-- | src/utf8.c | 39 |
1 files changed, 25 insertions, 14 deletions
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.12 2008/03/06 16:49:05 james + * *** empty log message *** + * * Revision 1.11 2008/03/03 06:04:42 james * *** empty log message *** * @@ -48,11 +51,12 @@ static char rcsid[] = "$Id$"; #include "project.h" -void +int utf8_flush (Context * c) { UTF8 *u = c->u; int i; + int err=0; switch (u->utf_ptr) { @@ -75,31 +79,35 @@ utf8_flush (Context * c) } for (i = 0; i < u->utf_ptr; ++i) - vt102_parse_char (c, u->utf_buf[i]); + err+=vt102_parse_char (c, u->utf_buf[i]); u->utf_ptr = 0; u->in_utf8 = 0; + + return err; + } -void +int utf8_parse (Context * c, uint32_t ch) { UTF8 *u = c->u; + int err=0; if (ch == SYM_CHAR_RESET) { u->in_utf8 = 0; - vt102_parse_char (c, ch); - return; + err+=vt102_parse_char (c, ch); + return err; } if (!u->in_utf8) { /*FIXME: for the moment we bodge utf8 support - need to do */ /* L->R and R->L and double width characters */ - if (ch == 0xb9) + if (ch == 0xb9) //FIXME - OTHER 8 bit control chars { /*CSI, not a valid utf8 start char */ - vt102_parse_char (c, ch); + err+=vt102_parse_char (c, ch); } else if ((ch & 0xe0) == 0xc0) { /*Start of two byte unicode sequence */ @@ -127,15 +135,15 @@ utf8_parse (Context * c, uint32_t ch) } else { - vt102_parse_char (c, ch); + err+=vt102_parse_char (c, ch); } } else { if ((ch & 0xc0) != 0x80) { - utf8_flush (c); - vt102_parse_char (c, ch); + err+=utf8_flush (c); + err+=vt102_parse_char (c, ch); } else { @@ -145,9 +153,10 @@ utf8_parse (Context * c, uint32_t ch) u->in_utf8--; if (!u->in_utf8) - vt102_parse_char (c, u->ch); + err+=vt102_parse_char (c, u->ch); } } +return err; } @@ -196,14 +205,16 @@ utf8_encode (char *ptr, int ch) return 0; } -void +int utf8_emit (TTY * t, int ch) { uint8_t buf[4]; int i; i = utf8_encode (buf, ch); if (!i) - return; + return 0; - t->xmit (t, buf, i); + if (t->xmit (t, buf, i)!=i) + return -1; + return 0; } |