[kaffe] CVS kaffe (kaz): libraries/javalib/kaffe/io/ByteToCharSHIFT_JIS.java,

Kaffe CVS cvs-commits at kaffe.org
Wed Nov 12 07:09:02 PST 2003


PatchSet 4159 
Date: 2003/11/12 15:06:24
Author: kaz
Branch: HEAD
Tag: (none) 
Log:
2003-11-12 Ito Kazumitsu <kaz at maczuka.gcd.org>

        libraries/javalib/kaffe/io/ByteToCharSHIFT_JIS.java,
        libraries/javalib/kaffe/io/ChartoByteSHIFT_JIS.java:
        New Files.

Members: 
	ChangeLog:1.1751->1.1752 
	libraries/javalib/kaffe/io/ByteToCharSHIFT_JIS.java:INITIAL->1.1 
	libraries/javalib/kaffe/io/CharToByteSHIFT_JIS.java:INITIAL->1.1 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1751 kaffe/ChangeLog:1.1752
--- kaffe/ChangeLog:1.1751	Tue Nov 11 14:34:43 2003
+++ kaffe/ChangeLog	Wed Nov 12 15:06:24 2003
@@ -1,3 +1,9 @@
+2003-11-12 Ito Kazumitsu <kaz at maczuka.gcd.org>
+
+	libraries/javalib/kaffe/io/ByteToCharSHIFT_JIS.java,
+	libraries/javalib/kaffe/io/ChartoByteSHIFT_JIS.java:
+	New Files.
+
 2003-11-11  Dalibor Topic <robilad at kaffe.org>
 
 	* kaffe/kaffevm/mem/gc-mem.c:
===================================================================
Checking out kaffe/libraries/javalib/kaffe/io/ByteToCharSHIFT_JIS.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/kaffe/io/ByteToCharSHIFT_JIS.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/kaffe/io/ByteToCharSHIFT_JIS.java	Wed Nov 12 15:08:34 2003
@@ -0,0 +1,42 @@
+/*
+ * Java core library component.
+ *
+ * Copyright (c) 2000
+ *      Transvirtual Technologies, Inc.  All rights reserved.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ *
+ * Byte to Char converter for SHIFT_JIS encoding.
+ *
+ * @author Ito Kazumitsu <kaz at maczuka.gcd.org>
+ *
+ */
+
+/*
+ * Without this class,  raw libiconv will be used for SHIFT_JIS encoding,
+ * in which case libiconv uses JIS X 0201 for characters below 0x80
+ * instead of US-ASCII.  That may be pedantically correct, but
+ * practically annoying.  In fact, Sun's implementation seems to
+ * use US-ASCII for characters below 0x80 even if the cocoding is
+ * SHIFT_THIS.
+ */ 
+package kaffe.io;
+
+public class ByteToCharSHIFT_JIS extends ByteToCharIconv {
+
+    public ByteToCharSHIFT_JIS() throws java.io.UnsupportedEncodingException {
+        super("SHIFT_JIS");
+    }
+
+    public int convert(byte[] from, int fpos, int flen, char[] to, int tpos, int tlen) {
+        int l = super.convert(from, fpos, flen, to, tpos, tlen);
+        int m = tpos + l;
+        for(int i = tpos; i < m; i++) {
+            if (to[i] == (char)0x00a5) to[i] = (char)'\\';
+            else if (to[i] == (char)0x203e) to[i] = (char)'~';
+        }
+        return l;
+    }
+
+}
===================================================================
Checking out kaffe/libraries/javalib/kaffe/io/CharToByteSHIFT_JIS.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/kaffe/io/CharToByteSHIFT_JIS.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/kaffe/io/CharToByteSHIFT_JIS.java	Wed Nov 12 15:08:36 2003
@@ -0,0 +1,42 @@
+/*
+ * Java core library component.
+ *
+ * Copyright (c) 2000
+ *      Transvirtual Technologies, Inc.  All rights reserved.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ *
+ * Char to Byte converter for SHIFT_JIS encoding.
+ *
+ * @author Ito Kazumitsu <kaz at maczuka.gcd.org>
+ *
+ */
+
+/*
+ * Without this class,  raw libiconv will be used for SHIFT_JIS encoding,
+ * in which case libiconv uses JIS X 0201 for characters below 0x80
+ * instead of US-ASCII.  That may be pedantically correct, but
+ * practically annoying.  In fact, Sun's implementation seems to
+ * use US-ASCII for characters below 0x80 even if the cocoding is
+ * SHIFT_THIS.
+ */ 
+package kaffe.io;
+
+public class CharToByteSHIFT_JIS extends CharToByteIconv {
+
+    public CharToByteSHIFT_JIS() throws java.io.UnsupportedEncodingException {
+        super("SHIFT_JIS");
+    }
+
+    public int convert(char[] from, int fpos, int flen, byte[] to, int tpos, int tlen) {
+        char[] buf = new char[flen];
+        for(int i = 0, j = fpos; i < flen; i++, j++) {
+            if (from[j] == (char)'\\') buf[i] = (char)0x00a5;
+            else if (from[j] == (char)'~') buf[i] = (char)0x203e;
+            else buf[i] = from[j];
+        }
+        return super.convert(buf, 0, flen, to, tpos, tlen);
+    }
+
+}




More information about the kaffe mailing list