8042125: Japanese character converters incompatible between Java 7 and Java 8
authorsherman
Mon, 25 May 2015 13:52:28 -0700
changeset 30794 fbf4c9ec6680
parent 30793 bd544d22247f
child 30795 7fff87625aba
8042125: Japanese character converters incompatible between Java 7 and Java 8 Summary: to add the missing .nr and c2b mapping tables Reviewed-by: okutsu
jdk/make/data/charsetmapping/JIS_X_0208_MS932.c2b
jdk/make/data/charsetmapping/JIS_X_0208_MS932.map
jdk/make/data/charsetmapping/JIS_X_0212_Solaris.map
jdk/test/sun/nio/cs/TestISO2022JP.java
jdk/test/sun/nio/cs/TestJIS0212Decoder.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/data/charsetmapping/JIS_X_0208_MS932.c2b	Mon May 25 13:52:28 2015 -0700
@@ -0,0 +1,7 @@
+0x2124    0x00b8
+0x2126    0x00b7
+0x2131    0x00af
+0x2263    0x00ab
+0x2264    0x00bb
+0x2574    0x3094
+0x264c    0x00b5
--- a/jdk/make/data/charsetmapping/JIS_X_0208_MS932.map	Mon May 25 19:09:44 2015 +0530
+++ b/jdk/make/data/charsetmapping/JIS_X_0208_MS932.map	Mon May 25 13:52:28 2015 -0700
@@ -1,7 +1,7 @@
 #
 #  mapping is based on JIS_X_0208_MS932_De/Encoder
 #
-#  moved following entries to .nr
+#  copied following entries to .nr
 #
 #   0x224c    0xffe2
 #   0x225d    0x22a5
@@ -14,7 +14,7 @@
 #   0x2d7b    0x2229
 #   0x2d7c    0x222a
 #
-#  and following to c2b
+#  and moved following to c2b
 #
 #   0x2124    0x00b8
 #   0x2126    0x00b7
@@ -144,13 +144,13 @@
 0x2241    0x2229
 0x224a    0x2227
 0x224b    0x2228
-#0x224c    0xffe2
+0x224c    0xffe2
 0x224d    0x21d2
 0x224e    0x21d4
 0x224f    0x2200
 0x2250    0x2203
 0x225c    0x2220
-#0x225d    0x22a5
+0x225d    0x22a5
 0x225e    0x2312
 0x225f    0x2202
 0x2260    0x2207
@@ -158,11 +158,11 @@
 0x2262    0x2252
 0x2263    0x226a
 0x2264    0x226b
-#0x2265    0x221a
+0x2265    0x221a
 0x2266    0x223d
 0x2267    0x221d
 0x2268    0x2235
-#0x2269    0x222b
+0x2269    0x222b
 0x226a    0x222c
 0x2272    0x212b
 0x2273    0x2030
@@ -620,19 +620,19 @@
 0x2d6d    0x337e
 0x2d6e    0x337d
 0x2d6f    0x337c
-#0x2d70    0x2252
-#0x2d71    0x2261
+0x2d70    0x2252
+0x2d71    0x2261
 0x2d72    0x222b
 0x2d73    0x222e
 0x2d74    0x2211
 0x2d75    0x221a
 0x2d76    0x22a5
-#0x2d77    0x2220
+0x2d77    0x2220
 0x2d78    0x221f
 0x2d79    0x22bf
-#0x2d7a    0x2235
-#0x2d7b    0x2229
-#0x2d7c    0x222a
+0x2d7a    0x2235
+0x2d7b    0x2229
+0x2d7c    0x222a
 0x3021    0x4e9c
 0x3022    0x5516
 0x3023    0x5a03
--- a/jdk/make/data/charsetmapping/JIS_X_0212_Solaris.map	Mon May 25 19:09:44 2015 +0530
+++ b/jdk/make/data/charsetmapping/JIS_X_0212_Solaris.map	Mon May 25 13:52:28 2015 -0700
@@ -23,7 +23,7 @@
 #    as the round-trip entries.
 #
 #    b2c and c2b all have entry "0x2271 <-> 0x2116", so the
-#    "0x742c -> 0x2116" entry is moved to the .nr table.
+#    "0x742c -> 0x2116" entry is copied to the .nr table.
 #
 #    mapping (c2b) generated from JIS_X_0212_Solaris_Encoder has
 #    two "dup" entries
@@ -6126,7 +6126,7 @@
 0x7429    0xff07
 0x742a    0xff02
 0x742b    0x3231
-#0x742c    0x2116
+0x742c    0x2116
 0x742d    0x2121
 0x742e    0x70bb
 0x742f    0x4efc
--- a/jdk/test/sun/nio/cs/TestISO2022JP.java	Mon May 25 19:09:44 2015 +0530
+++ b/jdk/test/sun/nio/cs/TestISO2022JP.java	Mon May 25 13:52:28 2015 -0700
@@ -22,7 +22,7 @@
  */
 
 /* @test
-   @bug 4626545 4879522 4913711 4119445
+   @bug 4626545 4879522 4913711 4119445 8042125
    @summary Check full coverage encode/decode for ISO-2022-JP
  */
 
@@ -33,6 +33,8 @@
  */
 
 import java.io.*;
+import java.util.Arrays;
+
 public class TestISO2022JP {
 
     private final static String US_ASCII =
@@ -608,5 +610,41 @@
             if (encoded[i] != expected[i])
                throw new Exception("ISO-2022-JP Decoder error");
         }
+
+        // Test for 7 c2b codepoints in ms932 iso2022jp
+        String testStr4 = "\u00b8\u00b7\u00af\u00ab\u00bb\u3094\u00b5";
+        expected = new byte[] {
+                     (byte)0x1b, (byte)0x24, (byte)0x42,
+                     (byte)0x21, (byte)0x24,
+                     (byte)0x21, (byte)0x26,
+                     (byte)0x21, (byte)0x31,
+                     (byte)0x22, (byte)0x63,
+                     (byte)0x22, (byte)0x64,
+                     (byte)0x25, (byte)0x74,
+                     (byte)0x26, (byte)0x4c,
+                     (byte)0x1b, (byte)0x28, (byte)0x42 };
+        encoded = testStr4.getBytes("x-windows-iso2022jp");
+        if (!Arrays.equals(encoded, expected)) {
+               throw new Exception("MSISO2022JP Encoder error");
+        }
+        // Test for 10 non-roundtrip characters in ms932 iso2022jp
+        encoded = new byte[] {
+            (byte)0x1B, (byte)0x24, (byte)0x42,
+            (byte)0x22, (byte)0x4C,
+            (byte)0x22, (byte)0x5D,
+            (byte)0x22, (byte)0x65,
+            (byte)0x22, (byte)0x69,
+            (byte)0x2D, (byte)0x70,
+            (byte)0x2D, (byte)0x71,
+            (byte)0x2D, (byte)0x77,
+            (byte)0x2D, (byte)0x7A,
+            (byte)0x2D, (byte)0x7B,
+            (byte)0x2D, (byte)0x7C,
+            (byte)0x1B, (byte)0x28, (byte)0x42,
+        };
+        String expectedStr = "\uffe2\u22a5\u221a\u222b\u2252\u2261\u2220\u2235\u2229\u222a";
+        if (!new String(encoded, "x-windows-iso2022jp").equals(expectedStr)) {
+               throw new Exception("MSISO2022JP Decoder error");
+        }
     }
 }
--- a/jdk/test/sun/nio/cs/TestJIS0212Decoder.java	Mon May 25 19:09:44 2015 +0530
+++ b/jdk/test/sun/nio/cs/TestJIS0212Decoder.java	Mon May 25 13:52:28 2015 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
-   @bug 4179800
+   @bug 4179800 8042125
    @summary Make sure JIS0212.Decoder really works
  */
 
@@ -38,25 +38,26 @@
                                             (byte)0x30, (byte)0x25, (byte)0x30, (byte)0x26,
                                             (byte)0x30, (byte)0x27};
 
-    public static void main(String args[])
-        throws Exception
-    {
+    public static void main(String args[]) throws Exception {
         test();
     }
 
-    private static void test()
-        throws Exception
-    {
+    private static void test() throws Exception {
         CharsetDecoder dec = Charset.forName("JIS0212").newDecoder();
         try {
             String ret = dec.decode(ByteBuffer.wrap(inputBytes)).toString();
             if (ret.length() != outputString.length()
                 || ! outputString.equals(ret)){
-                throw new Exception("ByteToCharJIS0212 does not work correctly");
+                throw new Exception("JIS0212 decoder does not work correctly");
             }
+        } catch (Exception e){
+            throw new Exception("JIS0212 encoder does not work correctly");
         }
-        catch (Exception e){
-            throw new Exception("ByteToCharJIS0212 does not work correctly");
+
+        // test 0x742c -> u2116 mapping
+        if (!"\u2116".equals(new String(new byte[] { (byte)0x8f, (byte)0xf4, (byte)0xac },
+                                        "x-eucJP-Open"))) {
+            throw new RuntimeException("JIS0212_Solaris nr mapping failed");
         }
     }
 }