4 * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
9 static char rcsid[] = "$Id$";
13 * Revision 1.4 2008/02/23 13:05:58 staffcvs
14 * *** empty log message ***
16 * Revision 1.3 2008/02/23 11:48:37 james
17 * *** empty log message ***
19 * Revision 1.2 2008/02/22 23:39:27 james
20 * *** empty log message ***
22 * Revision 1.1 2008/02/22 19:12:05 james
23 * *** empty log message ***
31 utf8_flush (Context * c)
39 log_f (c->l, "<invalid utf-8 sequence: \\%03o>", u->utf_buf[0]);
42 log_f (c->l, "<invalid utf-8 sequence: \\%03o \\%03o>",
43 u->utf_buf[0], u->utf_buf[1]);
46 log_f (c->l, "<invalid utf-8 sequence: \\%03o \\%03o \\%03o>",
47 u->utf_buf[0], u->utf_buf[1], u->utf_buf[2]);
51 "<invalid utf-8 sequence: \\%03o \\%03o \\%03o \\%03o>",
52 u->utf_buf[0], u->utf_buf[1], u->utf_buf[2], u->utf_buf[3]);
56 for (i = 0; i < u->utf_ptr; ++i)
57 vt102_parse_char (c, u->utf_buf[i]);
64 utf8_parse (Context * c, int ch)
68 if (ch == SYM_CHAR_RESET)
71 vt102_parse_char (c, ch);
77 /*FIXME: for the moment we bodge utf8 support */
79 { /*CSI, not a valid utf8 start char */
80 vt102_parse_char (c, ch);
82 else if ((ch & 0xe0) == 0xc0)
83 { /*Start of two byte unicode sequence */
86 u->utf_buf[u->utf_ptr++] = ch;
87 u->ch = (ch & 0x1f) << 6;
90 else if ((ch & 0xf0) == 0xe0)
91 { /*Start of three byte unicode sequence */
94 u->utf_buf[u->utf_ptr++] = ch;
95 u->ch = (ch & 0x0f) << 12;
98 else if ((ch & 0xf8) == 0xf0)
102 u->utf_buf[u->utf_ptr++] = ch;
103 u->ch = (ch & 0x07) << 18;
108 vt102_parse_char (c, ch);
113 if ((ch & 0xc0) != 0x80)
116 vt102_parse_char (c, ch);
120 u->utf_buf[u->utf_ptr++] = ch;
121 u->ch |= (ch & 0x3f) << u->sh;
126 vt102_parse_char (c, ch);
138 ret = (UTF8 *) malloc (sizeof (UTF8));