X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=charset%2Fcharconv.c;h=973d22c083ee0c15856422d9a77cba65705424af;hb=2b797fef8d8133e5b1cb40706aabc92718da40bd;hp=7cae74929d3be3b570b8c68ca9024e30fec2bb01;hpb=1571781022499a9d0c32d249f89945d034d1cbff;p=libucw.git diff --git a/charset/charconv.c b/charset/charconv.c index 7cae7492..973d22c0 100644 --- a/charset/charconv.c +++ b/charset/charconv.c @@ -1,10 +1,10 @@ /* - * Character Set Conversion Library 1.0 + * Character Set Conversion Library 1.1 * - * (c) 1998 Martin Mares + * (c) 1998--2001 Martin Mares * * This software may be freely distributed and used according to the terms - * of the GNU General Public License. + * of the GNU Lesser General Public License. */ #include "lib/lib.h" @@ -181,7 +181,7 @@ conv_to_utf8(struct conv_context *c) { if (d + 3 > de) goto dend; - *d++ = 0xc0 | (code >> 12); + *d++ = 0xe0 | (code >> 12); *d++ = 0x80 | ((code >> 6) & 0x3f); *d++ = 0x80 | (code & 0x3f); } @@ -258,3 +258,21 @@ conv_set_charset(struct conv_context *c, int src, int dest) } c->state = 0; } + +unsigned int +conv_x_to_ucs(unsigned int x) +{ + return x_to_uni[x]; +} + +unsigned int +conv_ucs_to_x(unsigned int ucs) +{ + return uni_to_x[ucs >> 8U][ucs & 0xff]; +} + +unsigned int +conv_x_count(void) +{ + return sizeof(x_to_uni) / sizeof(x_to_uni[0]); +}