diff options
author | james <> | 2008-02-24 00:47:14 +0000 |
---|---|---|
committer | james <> | 2008-02-24 00:47:14 +0000 |
commit | d338f6d46af0d6b5e746203748ba7cc9242020cb (patch) | |
tree | 3400ccf8db2c56670adfff5ced8a236d936b7588 /src/utf8.c | |
parent | 3240b828391da405d093356eae0b90af5abc7a32 (diff) | |
download | sympathy-d338f6d46af0d6b5e746203748ba7cc9242020cb.tar.gz sympathy-d338f6d46af0d6b5e746203748ba7cc9242020cb.tar.bz2 sympathy-d338f6d46af0d6b5e746203748ba7cc9242020cb.zip |
*** empty log message ***
Diffstat (limited to 'src/utf8.c')
-rw-r--r-- | src/utf8.c | 46 |
1 files changed, 43 insertions, 3 deletions
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.5 2008/02/24 00:42:53 james + * *** empty log message *** + * * Revision 1.4 2008/02/23 13:05:58 staffcvs * *** empty log message *** * @@ -61,7 +64,7 @@ utf8_flush (Context * c) } void -utf8_parse (Context * c, int ch) +utf8_parse (Context * c, uint32_t ch) { UTF8 *u = c->u; @@ -74,7 +77,8 @@ utf8_parse (Context * c, int ch) if (!u->in_utf8) { - /*FIXME: for the moment we bodge utf8 support */ + /*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); @@ -123,7 +127,7 @@ utf8_parse (Context * c, int ch) u->in_utf8--; if (!u->in_utf8) - vt102_parse_char (c, ch); + vt102_parse_char (c, u->ch); } } } @@ -140,3 +144,39 @@ utf8_new (void) ret->in_utf8 = 0; } + + + +void +utf8_emit (TTY * t, int ch) +{ + uint8_t buf[4]; + + if (ch < 0x80) + { + buf[0] = ch; + t->xmit (t, buf, 1); + } + else if (ch < 0x800) + { + buf[0] = 0xc0 | (ch >> 6); + buf[1] = 0x80 | (ch & 0x3f); + + t->xmit (t, buf, 2); + } + else if (ch < 0x10000) + { + buf[0] = 0xe0 | (ch >> 12); + buf[1] = 0x80 | ((ch >> 6) & 0x3f); + buf[2] = 0x80 | (ch & 0x3f); + t->xmit (t, buf, 3); + } + else if (ch < 0x1fffff) + { + buf[0] = 0xf0 | (ch >> 18); + buf[1] = 0x80 | ((ch >> 12) & 0x3f); + buf[2] = 0x80 | ((ch >> 6) & 0x3f); + buf[3] = 0x80 | (ch & 0x3f); + t->xmit (t, buf, 4); + } +} |