PatchSet 4216 
Date: 2003/12/12 15:42:53
Author: kaz
Branch: HEAD
Tag: (none) 
Log:
2003-12-12  Ito Kazumitsu  <[EMAIL PROTECTED]>

        * libraries/javalib/kaffe/io/CharToByteEUC_JP.java,
        libraries/javalib/kaffe/io/ByteToCharEUC_JP.java:
        Rewritten as an extension of CharToByteIconv and
        ByteToCharIconv.

        * kaffe/developers/README.EUC_JP:
        Added a comment on the change above.

        * libraries/javalib/kaffe/io/CharToByteEUC_JP.tbl,
        libraries/javalib/kaffe/io/ByteToCharEUC_JP.tbl:
        Deleted.

Members: 
        ChangeLog:1.1806->1.1807 
        developers/README.EUC_JP:1.1->1.2 
        libraries/javalib/kaffe/io/ByteToCharEUC_JP.java:1.2->1.3 
        libraries/javalib/kaffe/io/ByteToCharEUC_JP.tbl:1.1->1.2(DEAD) 
        libraries/javalib/kaffe/io/CharToByteEUC_JP.java:1.2->1.3 
        libraries/javalib/kaffe/io/CharToByteEUC_JP.tbl:1.1->1.2(DEAD) 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1806 kaffe/ChangeLog:1.1807
--- kaffe/ChangeLog:1.1806      Thu Dec 11 21:43:56 2003
+++ kaffe/ChangeLog     Fri Dec 12 15:42:53 2003
@@ -1,3 +1,17 @@
+2003-12-12  Ito Kazumitsu  <[EMAIL PROTECTED]>
+
+       * libraries/javalib/kaffe/io/CharToByteEUC_JP.java,
+       libraries/javalib/kaffe/io/ByteToCharEUC_JP.java:
+       Rewritten as an extension of CharToByteIconv and
+       ByteToCharIconv.
+
+       * kaffe/developers/README.EUC_JP:
+       Added a comment on the change above.
+
+       * libraries/javalib/kaffe/io/CharToByteEUC_JP.tbl,
+       libraries/javalib/kaffe/io/ByteToCharEUC_JP.tbl:
+       Deleted.
+
 2003-12-11  Ito Kazumitsu  <[EMAIL PROTECTED]>
 
        * libraries/javalib/kaffe/io/CharToByteEUC_JP.java:
Index: kaffe/developers/README.EUC_JP
diff -u kaffe/developers/README.EUC_JP:1.1 kaffe/developers/README.EUC_JP:1.2
--- kaffe/developers/README.EUC_JP:1.1  Thu Nov 30 03:32:46 2000
+++ kaffe/developers/README.EUC_JP      Fri Dec 12 15:42:54 2003
@@ -1,3 +1,9 @@
+# This is a historical document.
+# Classes kaffe.io.ByteToCharEUC_JP and kaffe.io.CharToByteEUC_JP use
+# Classes kaffe.io.ByteToCharIconv and kaffe.io.CharToByteIconv
+# respectively and the tables ByteToCharEUC_JP.tbl and CharToByteEUC_JP.tbl
+# are no longer used.  (Dec 12, 2003, Ito Kazumitsu <[EMAIL PROTECTED]>)
+
 Extended UNIX Code (EUC) Encoding Scheme
 
 The EUC encoding scheme defines a set of encoding rules that can
Index: kaffe/libraries/javalib/kaffe/io/ByteToCharEUC_JP.java
diff -u kaffe/libraries/javalib/kaffe/io/ByteToCharEUC_JP.java:1.2 
kaffe/libraries/javalib/kaffe/io/ByteToCharEUC_JP.java:1.3
--- kaffe/libraries/javalib/kaffe/io/ByteToCharEUC_JP.java:1.2  Sat Dec  2 02:10:18 
2000
+++ kaffe/libraries/javalib/kaffe/io/ByteToCharEUC_JP.java      Fri Dec 12 15:42:54 
2003
@@ -10,165 +10,21 @@
  * Byte to Char converter for EUC-JP encoding.
  * See also class EncodeEUC_JP in developers directory.
  *
- * @author Edouard G. Parmelan <[EMAIL PROTECTED]>
+ * @author Ito Kazumitsu <[EMAIL PROTECTED]>
  */
 
-package kaffe.io;
-
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.util.Arrays;
-
-public class ByteToCharEUC_JP extends ByteToCharConverter {
-    // Set this to false if you want handle exceptions defined in
-    // JIS-X-201 for US-ASCII range (0x5C '~' map to overline and 0x7E
-    // '\' to yen).  You must use the same value in classes
-    // kaffe.io.ByteToCharEUC_JP and kaffe.io.CharToByteEUC_JP.
-    private final static boolean US_ASCII = true;
-    
-    static boolean tableLoaded;
-    static String encodingRoot;
-
-    // Code set 1 (JIS X 0208): 0xA1A1-0xFEFE
-    static char[] cs1table;
-    static char[] uni1table;
-
-    // Code set 2 (half-width katakana): 0x8EA1-0x8EDF
-    static byte[] cs2table;
-    static char[] uni2table;
+/*
+ * This is only a wrapper of ByteToCharIconv for EUC-JP.
+ * The name "EUC-JP" cannot be used within a Java class name.
+ * So we use "EUC_JP" for "EUC-JP".
+ */ 
 
-    // Code set 3 (JIS X 0212-1990): 0x8FA1A1-0x8FFEFE
-    static char[] cs3table;
-    static char[] uni3table;
-
-    static {
-       tableLoaded = false;
-       encodingRoot = "kaffe.io";
-    }
-
-
-    public ByteToCharEUC_JP() {
-    }
-
-    public int convert(byte[] from, int fpos, int flen, char[] to, int tpos, int tlen 
) {
-       if (!tableLoaded) {
-           loadTable();
-       }
-       int o = tpos;
-       int oe = tpos + tlen;
-       int i = fpos;
-       int ie = fpos + flen;
-
-       for (; i < ie && o < oe; i++) {
-           int data = from[i] & 0xFF;
-           if ((data & 0x80) == 0) {
-               // Code set 0 (ASCII or JIS X 0201-1976 Roman): 0x21-0x7E
-               if (!US_ASCII) {
-                   // handle exceptions
-                   // 0x5C -> U+A5 YEN SIGN
-                   // 0x7E -> U+203E OVERLINE
-                   if (data == 0x5C) {
-                       data = 0xA5;
-                   }
-                   else if (data == 0x7E) {
-                       data = 0x203E;
-                   }
-               }
-               to[o++] = (char)data;
-           }
-           else if (data == 0x8E) {
-               // Code set 2 (half-width katakana): 0x8EA1-0x8EDF
-               // If we don't have enough data, bail.
-               if (i + 1 >= ie) {
-                   break;
-               }
-               i++;
-               data = from[i] & 0xFF;
-               int m = Arrays.binarySearch (cs2table, (byte)data);
-               if (m >= 0) {
-                   to[o++] = uni2table[m];
-               }
-               else {
-                   to[o++] = 0; // Error
-               }
-           }
-           else if (data == 0x8F) {
-               // Code set 3 (JIS X 0212-1990): 0x8FA1A1-0x8FFEFE
-               // If we don't have enough data, bail.
-               if (i + 2 >= ie) {
-                   break;
-               }
-               data = ((from[i + 1] & 0xFF) << 8) + (from[i + 2] & 0xFF);
-               i += 2;
-               int m = Arrays.binarySearch (cs3table, (char)data);
-               if (m >= 0) {
-                   to[o++] = uni3table[m];
-               }
-               else {
-                   to[o++] = 0; // Error
-               }
-           }
-           else {
-               // Code set 1 (JIS X 0208): 0xA1A1-0xFEFE
-               // If we don't have enough data, bail.
-               if (i + 1 >= ie) {
-                   break;
-               }
-               data = ((from[i] & 0xFF) << 8) + (from[i + 1] & 0xFF);
-               i += 1;
-               int m = Arrays.binarySearch (cs1table, (char)data);
-               if (m >= 0) {
-                   to[o++] = uni1table[m];
-               }
-               else {
-                   to[o++] = 0; // Error
-               }
-           }
-       }
-
-       if (ie > i) {
-           carry(from, i, ie - i);
-       }
+package kaffe.io;
 
-       return (o - tpos);
-    }
+public class ByteToCharEUC_JP extends ByteToCharIconv {
 
-    public int getNumberOfChars (byte[] from, int fpos, int flen ) {
-       return flen;
+    public ByteToCharEUC_JP() throws java.io.UnsupportedEncodingException {
+        super("EUC-JP");
     }
 
-    private static void loadTable() {
-       try {
-           String tablename = encodingRoot + ".ByteToCharEUC_JP";
-           InputStream in = 
ClassLoader.getSystemResourceAsStream(tablename.replace('.', '/') + ".tbl");
-           if (in != null) {
-               ObjectInputStream oin = new ObjectInputStream(in);
-               // Code set 1 (JIS X 0208): 0xA1A1-0xFEFE
-               cs1table = (char[])(oin.readObject());
-               uni1table = (char[])(oin.readObject());
-
-               // Code set 2 (half-width katakana): 0x8EA1-0x8EDF
-               cs2table = (byte[])(oin.readObject());
-               uni2table = (char[])(oin.readObject());
-
-               // Code set 3 (JIS X 0212-1990): 0x8FA1A1-0x8FFEFE
-               cs3table = (char[])(oin.readObject());
-               uni3table = (char[])(oin.readObject());
-
-               tableLoaded = true;
-           }
-       } catch (Exception e) {
-           System.err.println("ByteToCharEUC_JP.tbl could not be loaded" + e);
-       }
-       if(!tableLoaded) {
-           cs1table = new char[0];
-           uni1table = new char[0];
-           cs2table = new byte[0];
-           uni2table = new char[0];
-           cs3table = new char[0];
-           uni3table = new char[0];
-           tableLoaded = true;
-           System.err.println("CharToByteEUC_JP.tbl could not be loaded");
-       }
-    }
 }
===================================================================
Checking out kaffe/libraries/javalib/kaffe/io/ByteToCharEUC_JP.tbl
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/kaffe/io/Attic/ByteToCharEUC_JP.tbl,v
VERS: 1.1
***************
cvs [checkout aborted]: received broken pipe signal
Binary files - and /dev/null differ
Index: kaffe/libraries/javalib/kaffe/io/CharToByteEUC_JP.java
diff -u kaffe/libraries/javalib/kaffe/io/CharToByteEUC_JP.java:1.2 
kaffe/libraries/javalib/kaffe/io/CharToByteEUC_JP.java:1.3
--- kaffe/libraries/javalib/kaffe/io/CharToByteEUC_JP.java:1.2  Thu Dec 11 21:43:57 
2003
+++ kaffe/libraries/javalib/kaffe/io/CharToByteEUC_JP.java      Fri Dec 12 15:42:55 
2003
@@ -8,143 +8,17 @@
  * of this file.
  *
  * Char to Byte converter for EUC-JP encoding.
- * See also class EncodeEUC_JP in developers directory.
  *
  * @author Ito Kazumitsu <[EMAIL PROTECTED]>
  *
- * Modified by Edouard G. Parmelan <[EMAIL PROTECTED]> to add comments and
- * to handle exceptions in Code set 0.
  */
 
 package kaffe.io;
 
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.util.Arrays;
+public class CharToByteEUC_JP extends CharToByteIconv {
 
-public class CharToByteEUC_JP extends CharToByteConverter {
-    // Set this to false if you want handle exceptions defined in
-    // JIS-X-201 for US-ASCII range (0x5C '~' map to overline and 0x7E
-    // '\' to yen).  You must use the same value in classes
-    // kaffe.io.ByteToCharEUC_JP and kaffe.io.CharToByteEUC_JP.
-    private final static boolean US_ASCII = true;
-
-    static boolean tableLoaded;
-    static char[] utable;
-    static byte[] e1table;
-    static byte[] e2table;
-    static String encodingRoot;
-
-    static {
-       tableLoaded = false;
-       encodingRoot = "kaffe.io";
-    }
-
-    public CharToByteEUC_JP() {
-    }
-
-    public int convert (char[] from, int fpos, int flen, byte[] to, int tpos, int 
tlen ) {
-       if (!tableLoaded) {
-           loadTable();
-       }
-       int o = tpos;
-       int oe = tpos + tlen;
-       int i = fpos;
-       int ie = fpos + flen;
-
-       for (; i < ie; i++) {
-           char chr = from[i];
-           if (chr < 0x80) {
-               // Code set 0 (ASCII or JIS X 0201-1976 Roman): 0x21-0x7E
-               if (o >= oe) {
-                   break;
-               }
-               if (!US_ASCII) {
-                   // handled exceptions
-                   // 0x5C -> U+A5 YEN SIGN
-                   // 0x7E -> U+203E OVERLINE
-                   if (chr == 0xA5) {
-                       chr = 0x5C;
-                   }
-               }
-                   
-               if (o >= oe) {
-                   break;
-               }
-               to[o++] = (byte)chr;
-               continue;
-           }
-           if (!US_ASCII && (chr == 0x203E)) {
-               if (o >= oe) {
-                   break;
-               }
-               to[o++] = (byte)0x7E;
-               continue;
-           }
-           
-           int m = Arrays.binarySearch(utable, chr);
-           if (m >= 0) {
-               byte e1 = e1table[m];
-               byte e2 = e2table[m];
-               if (e1 > 0) {
-                   // Code set 3 (JIS X 0212-1990): 0x8FA1A1-0x8FFEFE
-                   if (o + 2 >= oe) {
-                       break;
-                   }
-                   to[o++] = (byte)0x8f;
-                   to[o++] = (byte)((int)e1 | 0x80);
-                   to[o++] = (byte)((int)e2 | 0x80);
-               }
-               else {
-                   //  Code set 1 (JIS X 0208): 0xA1A1-0xFEFE
-                   //  Code set 2 (half-width katakana): 0x8EA1-0x8EDF
-                   if (o + 1 >= oe) {
-                       break;
-                   }
-                   to[o++] = e1;
-                   to[o++] = e2;
-               }
-           }
-           else {
-               if (o >= oe) {
-                   break;
-               }
-               to[o++] = (byte)'?'; // Error
-           }
-       }
-
-       // Carry anything left.
-       if (ie > i) {
-           carry(from, i, ie - i);
-       }
-
-       return (o - tpos);
+    public CharToByteEUC_JP() throws java.io.UnsupportedEncodingException {
+        super("EUC-JP");
     }
 
-    public int getNumberOfBytes ( char[] from, int fpos, int flen ) {
-       return flen; // This may return something wrong, but I do not care.
-    }
-
-    private static void loadTable() {
-       try {
-           String tablename = encodingRoot + ".CharToByteEUC_JP";
-           InputStream in = 
ClassLoader.getSystemResourceAsStream(tablename.replace('.', '/') + ".tbl");
-           if (in != null) {
-               ObjectInputStream oin = new ObjectInputStream(in);
-               utable = (char[])(oin.readObject());
-               e1table = (byte[])(oin.readObject());
-               e2table = (byte[])(oin.readObject());
-               tableLoaded = true;
-           }
-       } catch (Exception e) {
-           System.err.println("CharToByteEUC_JP.tbl could not be loaded" + e);
-       }
-       if(!tableLoaded) {
-           utable = new char[0];
-           e1table = new byte[0];
-           e2table = new byte[0];
-           tableLoaded = true;
-           System.err.println("CharToByteEUC_JP.tbl could not be loaded");
-       }
-    }
 }
===================================================================
Checking out kaffe/libraries/javalib/kaffe/io/CharToByteEUC_JP.tbl
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/kaffe/io/Attic/CharToByteEUC_JP.tbl,v
VERS: 1.1
***************
cvs [checkout aborted]: received broken pipe signal
Binary files - and /dev/null differ

_______________________________________________
kaffe mailing list
[EMAIL PROTECTED]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to