796
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
|
796
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
5506
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
796
|
22 |
*/
|
|
23 |
|
|
24 |
/* @test
|
|
25 |
@bug 6529796 6710199
|
|
26 |
@summary Test SJIS/MS932_0213 charsets
|
|
27 |
*/
|
|
28 |
|
|
29 |
import java.util.Arrays;
|
|
30 |
|
|
31 |
public class TestSJIS0213 {
|
|
32 |
private static String sjisStr = "\u2014\u301C\u2016\u2212\u00A2\u00A3\u00AC";
|
|
33 |
private static String winStr = "\u2015\uFF5E\u2225\uFF0D\uFFE0\uFFE1\uFFE2\u2252\u2261\u222B\u2211\u221A\u22A5\u2220\u2235\u2229\u222A";
|
|
34 |
|
|
35 |
private static String compStr = "\u304B\u309A\u304D\u309A\u304F\u309A\u3051\u309A\u3053\u309A\u30AB\u309A\u30AD\u309A\u30AF\u309A\u30B1\u309A\u30B3\u309A\u30BB\u309A\u30C4\u309A\u30C8\u309A\u31F7\u309A\u00E6\u0300\u0254\u0300\u0254\u0301\u028C\u0300\u028C\u0301\u0259\u0300\u0259\u0301\u025A\u0300\u025A\u0301\u02E9\u02E5\u02E5\u02E9";
|
|
36 |
private static byte[] compBytes = new byte[] {
|
|
37 |
(byte)0x82, (byte)0xf5,
|
|
38 |
(byte)0x82, (byte)0xf6,
|
|
39 |
(byte)0x82, (byte)0xf7,
|
|
40 |
(byte)0x82, (byte)0xf8,
|
|
41 |
(byte)0x82, (byte)0xf9,
|
|
42 |
(byte)0x83, (byte)0x97,
|
|
43 |
(byte)0x83, (byte)0x98,
|
|
44 |
(byte)0x83, (byte)0x99,
|
|
45 |
(byte)0x83, (byte)0x9a,
|
|
46 |
(byte)0x83, (byte)0x9b,
|
|
47 |
(byte)0x83, (byte)0x9c,
|
|
48 |
(byte)0x83, (byte)0x9d,
|
|
49 |
(byte)0x83, (byte)0x9e,
|
|
50 |
(byte)0x83, (byte)0xf6,
|
|
51 |
(byte)0x86, (byte)0x63,
|
|
52 |
(byte)0x86, (byte)0x67,
|
|
53 |
(byte)0x86, (byte)0x68,
|
|
54 |
(byte)0x86, (byte)0x69,
|
|
55 |
(byte)0x86, (byte)0x6a,
|
|
56 |
(byte)0x86, (byte)0x6b,
|
|
57 |
(byte)0x86, (byte)0x6c,
|
|
58 |
(byte)0x86, (byte)0x6d,
|
|
59 |
(byte)0x86, (byte)0x6e,
|
|
60 |
(byte)0x86, (byte)0x85,
|
|
61 |
(byte)0x86, (byte)0x86 };
|
|
62 |
|
|
63 |
private static String mixedStr = "\u002B\u0041\u007a\uff61\uff9f\u3000\u30a1\u4e00\u304B\u309A\u304b";
|
|
64 |
private static byte[] mixedBytes = new byte[] {
|
|
65 |
(byte)0x2b,
|
|
66 |
(byte)0x41, (byte)0x7a,
|
|
67 |
(byte)0xa1, (byte)0xdf,
|
|
68 |
(byte)0x81, (byte)0x40,
|
|
69 |
(byte)0x83, (byte)0x40,
|
|
70 |
(byte)0x88, (byte)0xea,
|
|
71 |
(byte)0x82, (byte)0xf5, // composite
|
|
72 |
(byte)0x82, (byte)0xa9 }; // base without cc
|
|
73 |
|
|
74 |
//base + base + cc
|
|
75 |
private static String mixedCompStr = "\u304D\u304B\u309A";
|
|
76 |
private static byte[] mixedCompBytes = new byte[] {
|
|
77 |
(byte)0x82, (byte)0xab, (byte)0x82, (byte)0xf5};
|
|
78 |
|
|
79 |
private static char[] unmappableChars = new char[] {
|
|
80 |
0x80, 0xfffc, 0xfffd};
|
|
81 |
|
|
82 |
private static byte[] unmappableBytes = new byte[] {
|
|
83 |
0x3f, 0x3f, 0x3f};
|
|
84 |
|
|
85 |
public static void main(String[] args) throws Exception {
|
|
86 |
if (!winStr.equals(new String(winStr.getBytes("MS932"), "MS932_0213")))
|
|
87 |
throw new RuntimeException("MS932_0213 failed on special codepoints!");
|
|
88 |
|
|
89 |
if (!(Arrays.equals(compStr.getBytes("MS932_0213"), compBytes)) ||
|
|
90 |
!compStr.equals(new String(compBytes, "MS932_0213")))
|
|
91 |
throw new RuntimeException("MS932_0213 failed on composites!");
|
|
92 |
|
|
93 |
if (!(Arrays.equals(mixedStr.getBytes("MS932_0213"), mixedBytes)) ||
|
|
94 |
!mixedStr.equals(new String(mixedBytes, "MS932_0213")))
|
|
95 |
throw new RuntimeException("MS932_0213 failed on mixed!");
|
|
96 |
|
|
97 |
if (!sjisStr.equals(new String(sjisStr.getBytes("SJIS"), "SJIS_0213")))
|
|
98 |
throw new RuntimeException("SJIS_0213 failed on special codepoints!");
|
|
99 |
|
|
100 |
if (!(Arrays.equals(compStr.getBytes("SJIS_0213"), compBytes)) ||
|
|
101 |
!compStr.equals(new String(compBytes, "SJIS_0213")))
|
|
102 |
throw new RuntimeException("SJIS_0213 failed on composites!");
|
|
103 |
|
|
104 |
if (!(Arrays.equals(mixedStr.getBytes("SJIS_0213"), mixedBytes)) ||
|
|
105 |
!mixedStr.equals(new String(mixedBytes, "SJIS_0213")))
|
|
106 |
throw new RuntimeException("SJIS_0213 failed on mixed!");
|
|
107 |
|
|
108 |
if (!(Arrays.equals(mixedCompStr.getBytes("SJIS_0213"), mixedCompBytes)) ||
|
|
109 |
!mixedCompStr.equals(new String(mixedCompBytes, "SJIS_0213")))
|
|
110 |
throw new RuntimeException("SJIS_0213 failed on mixedComp!");
|
|
111 |
|
|
112 |
if (!Arrays.equals(new String(unmappableChars).getBytes("SJIS_0213"), unmappableBytes) ||
|
|
113 |
!Arrays.equals(new String(unmappableChars).getBytes("MS932_0213"), unmappableBytes))
|
|
114 |
throw new RuntimeException("SJIS/MS932_0213 failed on unmappable encoding!");
|
|
115 |
}
|
|
116 |
}
|