4 * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
9 static char rcsid[] = "$Id$";
13 * Revision 1.3 2008/02/23 11:48:37 james
14 * *** empty log message ***
16 * Revision 1.2 2008/02/22 23:39:27 james
17 * *** empty log message ***
19 * Revision 1.1 2008/02/22 19:12:05 james
20 * *** empty log message ***
28 utf8_flush (Context * c)
36 log_f (c->l, "%s:%d invalid utf-8 sequence: \\%03o",
37 __FILE__, __LINE__, u->utf_buf[0]);
40 log_f (c->l, "%s:%d invalid utf-8 sequence: \\%03o \\%03o",
41 __FILE__, __LINE__, u->utf_buf[0], u->utf_buf[1]);
44 log_f (c->l, "%s:%d invalid utf-8 sequence: \\%03o \\%03o \\%03o",
45 __FILE__, __LINE__, u->utf_buf[0], u->utf_buf[1], u->utf_buf[2]);
49 "%s:%d invalid utf-8 sequence: \\%03o \\%03o \\%03o \\%03o",
51 u->utf_buf[0], u->utf_buf[1], u->utf_buf[2], u->utf_buf[3]);
55 for (i = 0; i < u->utf_ptr; ++i)
56 vt102_parse_char (c, u->utf_buf[i]);
63 utf8_parse (Context * c, int ch)
67 if (ch == SYM_CHAR_RESET)
70 vt102_parse_char (c, ch);
76 /*FIXME: for the moment we bodge utf8 support */
78 { /*CSI, not a valid utf8 start char */
79 vt102_parse_char (c, ch);
81 else if ((ch & 0xe0) == 0xc0)
82 { /*Start of two byte unicode sequence */
85 u->utf_buf[u->utf_ptr++] = ch;
86 u->ch = (ch & 0x1f) << 6;
89 else if ((ch & 0xf0) == 0xe0)
90 { /*Start of three byte unicode sequence */
93 u->utf_buf[u->utf_ptr++] = ch;
94 u->ch = (ch & 0x0f) << 12;
97 else if ((ch & 0xf8) == 0xf0)
101 u->utf_buf[u->utf_ptr++] = ch;
102 u->ch = (ch & 0x07) << 18;
107 vt102_parse_char (c, ch);
112 if ((ch & 0xc0) != 0x80)
115 vt102_parse_char (c, ch);
119 u->utf_buf[u->utf_ptr++] = ch;
120 u->ch |= (ch & 0x3f) << u->sh;
125 vt102_parse_char (c, ch);
137 ret = (UTF8 *) malloc (sizeof (UTF8));