diff options
author | james <> | 2008-02-27 01:31:14 +0000 |
---|---|---|
committer | james <> | 2008-02-27 01:31:14 +0000 |
commit | 4add819b42c292ee2a6fc4aeda782a447b1bcf27 (patch) | |
tree | 17b7f7ce7e45c6c6262db7cfeb548a4d6f1006e1 /src/utf8.c | |
parent | 74feb0db53bf6ed2d53ca59e3aed001f1160e62a (diff) | |
download | sympathy-4add819b42c292ee2a6fc4aeda782a447b1bcf27.tar.gz sympathy-4add819b42c292ee2a6fc4aeda782a447b1bcf27.tar.bz2 sympathy-4add819b42c292ee2a6fc4aeda782a447b1bcf27.zip |
*** empty log message ***
Diffstat (limited to 'src/utf8.c')
-rw-r--r-- | src/utf8.c | 25 |
1 files changed, 15 insertions, 10 deletions
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$"; /* * $Log$ + * Revision 1.9 2008/02/27 01:31:14 james + * *** empty log message *** + * * Revision 1.8 2008/02/27 00:54:16 james * *** empty log message *** * @@ -154,26 +157,27 @@ utf8_new (void) } -int utf8_encode (char *ptr, int ch) +int +utf8_encode (char *ptr, int ch) { if (ch < 0x80) { ptr[0] = ch; - return 1; + return 1; } else if (ch < 0x800) { ptr[0] = 0xc0 | (ch >> 6); ptr[1] = 0x80 | (ch & 0x3f); - return 2; + return 2; } else if (ch < 0x10000) { ptr[0] = 0xe0 | (ch >> 12); ptr[1] = 0x80 | ((ch >> 6) & 0x3f); ptr[2] = 0x80 | (ch & 0x3f); - return 3; + return 3; } else if (ch < 0x1fffff) { @@ -181,18 +185,19 @@ int utf8_encode (char *ptr, int ch) ptr[1] = 0x80 | ((ch >> 12) & 0x3f); ptr[2] = 0x80 | ((ch >> 6) & 0x3f); ptr[3] = 0x80 | (ch & 0x3f); - return 4; + return 4; } - return 0; + return 0; } void utf8_emit (TTY * t, int ch) { uint8_t buf[4]; -int i; - i=utf8_encode(buf,ch); - if (!i) return; + int i; + i = utf8_encode (buf, ch); + if (!i) + return; - t->xmit (t, buf, i); + t->xmit (t, buf, i); } |