]> mj.ucw.cz Git - libucw.git/blobdiff - charset/charconv.c
Fixed bug in generating UTF-8 for codes >= 0x800.
[libucw.git] / charset / charconv.c
index 7cae74929d3be3b570b8c68ca9024e30fec2bb01..996495cac0cda6ad26bc5f56332865590da1c5f5 100644 (file)
@@ -1,7 +1,7 @@
 /*
- *     Character Set Conversion Library 1.0
+ *     Character Set Conversion Library 1.1
  *
- *     (c) 1998 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ *     (c) 1998--2001 Martin Mares <mj@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU General Public License.
@@ -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]);
+}