From: Martin Mares Date: Fri, 7 Jan 2005 23:42:11 +0000 (+0000) Subject: Added functions for single-character conversions between selected X-Git-Tag: holmes-import~844 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=0bb4ed9f0708e3b08e7f7c37cae7c765e7a01366;p=libucw.git Added functions for single-character conversions between selected character sets and Unicode, with no interpolation. --- diff --git a/charset/charconv.c b/charset/charconv.c index 67e84555..fcd8680c 100644 --- a/charset/charconv.c +++ b/charset/charconv.c @@ -412,3 +412,18 @@ conv_x_count(void) { return sizeof(x_to_uni) / sizeof(x_to_uni[0]); } + +int +conv_in_to_ucs(struct conv_context *c, unsigned int y) +{ + return x_to_uni[c->in_to_x[y]]; +} + +int conv_ucs_to_out(struct conv_context *c, unsigned int ucs) +{ + uns x = uni_to_x[ucs >> 8U][ucs & 0xff]; + if (x == 256 || c->x_to_out[x] >= 256) + return -1; + else + return c->x_to_out[x]; +} diff --git a/charset/charconv.h b/charset/charconv.h index 9685e77f..172c3fa6 100644 --- a/charset/charconv.h +++ b/charset/charconv.h @@ -63,6 +63,10 @@ enum charset_id { CONV_NUM_CHARSETS }; +/* Conversion of a single character between current charset to Unicode */ +int conv_in_to_ucs(struct conv_context *c, unsigned int y); +int conv_ucs_to_out(struct conv_context *c, unsigned int ucs); + /* For those brave ones who want to mess with charconv internals */ unsigned int conv_x_to_ucs(unsigned int x); unsigned int conv_ucs_to_x(unsigned int ucs);