[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: gb <==> big5 conversion module (32K attached)



Hello everyone,

Attached (attachment 1) is the gb-big5 gconv module as promised. The source
file is too big ( > 100k) to mail to this list. If you want email me ask
for it, but actually you can reproduce the mapping table by using the module
itself. The mapping table is made by myself, and is different from all
existing ones. The description of the mapping table will be in a separate
email, I'm too tired today, sorry. Please test the module and send me
your comments.

The gconv module was compiled under the newly released glibc 2.2.1. It should
also works on 2.2. Though I don't know if it works on 2.1.x.

To install the module:

#bunzip2 GBBIG5.so.bz2
#cp GBBIG5.so /usr/lib/gconv/GBBIG5.so

add the following 2 lines in your /usr/lib/gconv/gconv-modules
module  EUC-CN//                BIG5//                  GBBIG5          1
module  BIG5//                  EUC-CN//                GBBIG5          1


Then you can use iconv to convert between gb and big5. The best way is using
"-c" option which tells iconv to ignore conversion errors. This is necessary
because, after all, there are characters can not be mapped to the other
encoding. Without "-c", iconv will stop when it encounters such a character,
the rest of the file will not be converted even if they are all map-able
characters. Using a "-c", iconv will output a box character for the unmapped
character and go on, just like what other converter programs (hc3, autoconvert)
do.

Unfortunately because few bugs "-c" option does not work in glibc 2.2.1.
With or without it, iconv always stops when it see an illegal character.
To make it work you have to apply a patch (attachment 2). I'll submit the
patch to glibc tomorrow.

Happy new year, and
Have an enjoyable and fruitful year of little dragon,

rigel

Attachment: GBBIG5.so.bz2
Description: BZip2 compressed data

diff -Naur glibc-2.2.1.orig/iconv/gconv_open.c glibc-2.2.1/iconv/gconv_open.c
--- glibc-2.2.1.orig/iconv/gconv_open.c	Mon Sep 11 05:42:57 2000
+++ glibc-2.2.1/iconv/gconv_open.c	Tue Jan 23 01:47:21 2001
@@ -35,7 +35,6 @@
   __gconv_t result = NULL;
   size_t cnt = 0;
   int res;
-  int conv_flags = 0;
   const char *errhand;
   const char *ignore;
   struct trans_struct *trans = NULL;
@@ -247,7 +246,7 @@
 		 output buffer.  */
 	      if (cnt < nsteps - 1)
 		{
-		  result->__data[cnt].__flags = conv_flags;
+		  result->__data[cnt].__flags = flags;
 
 		  /* Allocate the buffer.  */
 		  size = (GCONV_NCHAR_GOAL * steps[cnt].__max_needed_to);
@@ -265,7 +264,7 @@
 	      else
 		{
 		  /* Handle the last entry.  */
-		  result->__data[cnt].__flags = conv_flags | __GCONV_IS_LAST;
+		  result->__data[cnt].__flags = flags | __GCONV_IS_LAST;
 
 		  break;
 		}
diff -Naur glibc-2.2.1.orig/iconv/iconv_prog.c glibc-2.2.1/iconv/iconv_prog.c
--- glibc-2.2.1.orig/iconv/iconv_prog.c	Sat Jan 13 15:09:08 2001
+++ glibc-2.2.1/iconv/iconv_prog.c	Tue Jan 23 01:49:39 2001
@@ -168,7 +168,7 @@
       cp = mempcpy (newp, to_code, errhand - to_code);
       while (nslash-- > 0)
 	*cp++ = '/';
-      memcpy (cp, "NEEDED", sizeof ("NEEDED"));
+      memcpy (cp, "IGNORE", sizeof ("IGNORE"));
 
       to_code = newp;
     }

Reply to: