395N/A/*
2362N/A * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
395N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
395N/A *
395N/A * This code is free software; you can redistribute it and/or modify it
395N/A * under the terms of the GNU General Public License version 2 only, as
395N/A * published by the Free Software Foundation.
395N/A *
395N/A * This code is distributed in the hope that it will be useful, but WITHOUT
395N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
395N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
395N/A * version 2 for more details (a copy is included in the LICENSE file that
395N/A * accompanied this code).
395N/A *
395N/A * You should have received a copy of the GNU General Public License version
395N/A * 2 along with this work; if not, write to the Free Software Foundation,
395N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
395N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
395N/A */
395N/A
395N/A/* @test
395N/A @bug 6529796 6710199
395N/A @summary Test SJIS/MS932_0213 charsets
395N/A */
395N/A
395N/Aimport java.util.Arrays;
395N/A
395N/Apublic class TestSJIS0213 {
395N/A private static String sjisStr = "\u2014\u301C\u2016\u2212\u00A2\u00A3\u00AC";
395N/A private static String winStr = "\u2015\uFF5E\u2225\uFF0D\uFFE0\uFFE1\uFFE2\u2252\u2261\u222B\u2211\u221A\u22A5\u2220\u2235\u2229\u222A";
395N/A
395N/A 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";
395N/A private static byte[] compBytes = new byte[] {
395N/A (byte)0x82, (byte)0xf5,
395N/A (byte)0x82, (byte)0xf6,
395N/A (byte)0x82, (byte)0xf7,
395N/A (byte)0x82, (byte)0xf8,
395N/A (byte)0x82, (byte)0xf9,
395N/A (byte)0x83, (byte)0x97,
395N/A (byte)0x83, (byte)0x98,
395N/A (byte)0x83, (byte)0x99,
395N/A (byte)0x83, (byte)0x9a,
395N/A (byte)0x83, (byte)0x9b,
395N/A (byte)0x83, (byte)0x9c,
395N/A (byte)0x83, (byte)0x9d,
395N/A (byte)0x83, (byte)0x9e,
395N/A (byte)0x83, (byte)0xf6,
395N/A (byte)0x86, (byte)0x63,
395N/A (byte)0x86, (byte)0x67,
395N/A (byte)0x86, (byte)0x68,
395N/A (byte)0x86, (byte)0x69,
395N/A (byte)0x86, (byte)0x6a,
395N/A (byte)0x86, (byte)0x6b,
395N/A (byte)0x86, (byte)0x6c,
395N/A (byte)0x86, (byte)0x6d,
395N/A (byte)0x86, (byte)0x6e,
395N/A (byte)0x86, (byte)0x85,
395N/A (byte)0x86, (byte)0x86 };
395N/A
395N/A private static String mixedStr = "\u002B\u0041\u007a\uff61\uff9f\u3000\u30a1\u4e00\u304B\u309A\u304b";
395N/A private static byte[] mixedBytes = new byte[] {
395N/A (byte)0x2b,
395N/A (byte)0x41, (byte)0x7a,
395N/A (byte)0xa1, (byte)0xdf,
395N/A (byte)0x81, (byte)0x40,
395N/A (byte)0x83, (byte)0x40,
395N/A (byte)0x88, (byte)0xea,
395N/A (byte)0x82, (byte)0xf5, // composite
395N/A (byte)0x82, (byte)0xa9 }; // base without cc
395N/A
395N/A //base + base + cc
395N/A private static String mixedCompStr = "\u304D\u304B\u309A";
395N/A private static byte[] mixedCompBytes = new byte[] {
395N/A (byte)0x82, (byte)0xab, (byte)0x82, (byte)0xf5};
395N/A
395N/A private static char[] unmappableChars = new char[] {
395N/A 0x80, 0xfffc, 0xfffd};
395N/A
395N/A private static byte[] unmappableBytes = new byte[] {
395N/A 0x3f, 0x3f, 0x3f};
395N/A
395N/A public static void main(String[] args) throws Exception {
395N/A if (!winStr.equals(new String(winStr.getBytes("MS932"), "MS932_0213")))
395N/A throw new RuntimeException("MS932_0213 failed on special codepoints!");
395N/A
395N/A if (!(Arrays.equals(compStr.getBytes("MS932_0213"), compBytes)) ||
395N/A !compStr.equals(new String(compBytes, "MS932_0213")))
395N/A throw new RuntimeException("MS932_0213 failed on composites!");
395N/A
395N/A if (!(Arrays.equals(mixedStr.getBytes("MS932_0213"), mixedBytes)) ||
395N/A !mixedStr.equals(new String(mixedBytes, "MS932_0213")))
395N/A throw new RuntimeException("MS932_0213 failed on mixed!");
395N/A
395N/A if (!sjisStr.equals(new String(sjisStr.getBytes("SJIS"), "SJIS_0213")))
395N/A throw new RuntimeException("SJIS_0213 failed on special codepoints!");
395N/A
395N/A if (!(Arrays.equals(compStr.getBytes("SJIS_0213"), compBytes)) ||
395N/A !compStr.equals(new String(compBytes, "SJIS_0213")))
395N/A throw new RuntimeException("SJIS_0213 failed on composites!");
395N/A
395N/A if (!(Arrays.equals(mixedStr.getBytes("SJIS_0213"), mixedBytes)) ||
395N/A !mixedStr.equals(new String(mixedBytes, "SJIS_0213")))
395N/A throw new RuntimeException("SJIS_0213 failed on mixed!");
395N/A
395N/A if (!(Arrays.equals(mixedCompStr.getBytes("SJIS_0213"), mixedCompBytes)) ||
395N/A !mixedCompStr.equals(new String(mixedCompBytes, "SJIS_0213")))
395N/A throw new RuntimeException("SJIS_0213 failed on mixedComp!");
395N/A
395N/A if (!Arrays.equals(new String(unmappableChars).getBytes("SJIS_0213"), unmappableBytes) ||
395N/A !Arrays.equals(new String(unmappableChars).getBytes("MS932_0213"), unmappableBytes))
395N/A throw new RuntimeException("SJIS/MS932_0213 failed on unmappable encoding!");
395N/A }
395N/A}