]> mj.ucw.cz Git - libucw.git/commitdiff
Added functions for single-character conversions between selected
authorMartin Mares <mj@ucw.cz>
Fri, 7 Jan 2005 23:42:11 +0000 (23:42 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 7 Jan 2005 23:42:11 +0000 (23:42 +0000)
character sets and Unicode, with no interpolation.

charset/charconv.c
charset/charconv.h

index 67e84555f76d862f5fb84acd8fd546d3f9e61a6d..fcd8680c438af7d7b847089149db4cf82657737b 100644 (file)
@@ -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];
+}
index 9685e77f55878ae5d72af7f9bca42affcd2ffd14..172c3fa6f191f221740a50b7e68e8c19120dd135 100644 (file)
@@ -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);