-UTF8 *u=&c->u;
-
- if (!u->in_utf8) {
- /*FIXME: for the moment we bodge utf8 support*/
- if (ch==0xb9) { /*CSI, not a valid utf8 start char*/
- vt102_parse(c,ch);
- } else if ((ch & 0xe0) == 0xc0) { /*Start of two byte unicode sequence*/
- u->in_utf8=2;
- u->utf_ptr=0;
- u->utf_buf[u->utf_ptr++]=ch;
- } else if ((ch & 0xf0) ==0xe0) { /*Start of three byte unicode sequence*/
- u->in_utf8=3;
- u->utf_ptr=0;
- u->utf_buf[u->utf_ptr++]=ch;
- } else if ((ch & 0xf8) ==0xf0) {
- u->in_utf8=4;
- u->utf_ptr=0;
- u->utf_buf[u->utf_ptr++]=ch;
- } else {
- vt102_parse(c,ch);
- }
- } else {
- if ((ch & 0xc0) != 0x80) {
- utf8_flush(c);
- vt102_parse(c,ch);
- } else {
- u->utf_buf[u->utf_ptr++]=ch;
- u->in_utf8--;
- }
- }
+ UTF8 *u = c->u;
+
+ if (ch == SYM_CHAR_RESET)
+ {
+ u->in_utf8 = 0;
+ vt102_parse_char (c, ch);
+ return;
+ }
+
+ 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)
+ { /*CSI, not a valid utf8 start char */
+ vt102_parse_char (c, ch);
+ }
+ else if ((ch & 0xe0) == 0xc0)
+ { /*Start of two byte unicode sequence */
+ u->in_utf8 = 1;
+ u->utf_ptr = 0;
+ u->utf_buf[u->utf_ptr++] = ch;
+ u->ch = (ch & 0x1f) << 6;
+ u->sh = 0;
+ }
+ else if ((ch & 0xf0) == 0xe0)
+ { /*Start of three byte unicode sequence */
+ u->in_utf8 = 2;
+ u->utf_ptr = 0;
+ u->utf_buf[u->utf_ptr++] = ch;
+ u->ch = (ch & 0x0f) << 12;
+ u->sh = 6;
+ }
+ else if ((ch & 0xf8) == 0xf0)
+ {
+ u->in_utf8 = 3;
+ u->utf_ptr = 0;
+ u->utf_buf[u->utf_ptr++] = ch;
+ u->ch = (ch & 0x07) << 18;
+ u->sh = 12;
+ }
+ else
+ {
+ vt102_parse_char (c, ch);
+ }
+ }
+ else
+ {
+ if ((ch & 0xc0) != 0x80)
+ {
+ utf8_flush (c);
+ vt102_parse_char (c, ch);
+ }
+ else
+ {
+ u->utf_buf[u->utf_ptr++] = ch;
+ u->ch |= (ch & 0x3f) << u->sh;
+ u->sh -= 6;
+ u->in_utf8--;
+
+ if (!u->in_utf8)
+ vt102_parse_char (c, u->ch);
+ }
+ }