X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=charset%2Fcharconv.c;h=996495cac0cda6ad26bc5f56332865590da1c5f5;hb=c7b8fa1cf1dae26c8a852f6e3e67e96da7209741;hp=8da42ffec31ab13e81fca811fcb55b473ba894e4;hpb=5451cada955bd952f5c732857e27ed676e873aa1;p=libucw.git diff --git a/charset/charconv.c b/charset/charconv.c index 8da42ffe..996495ca 100644 --- a/charset/charconv.c +++ b/charset/charconv.c @@ -1,18 +1,15 @@ /* - * 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. */ -#include "charconv.h" -#include "chartable.h" - -#ifndef NULL -#define NULL ((void *)0) -#endif +#include "lib/lib.h" +#include "charset/charconv.h" +#include "charset/chartable.h" void conv_init(struct conv_context *c) @@ -184,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); } @@ -261,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]); +}