Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/nio/cs/HWKatakanaMS932EncodeTest.java
38839 views
/*1* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/* @test24@bug 471533025@summary Check MS932/windows-31j encoding (char->byte) for halfwidth katakana chars26*/2728/*29* Tests encodeability of the Unicode defined Halfwidth Katakana30* characters using the MS932/windows-31j encoder31*/3233public class HWKatakanaMS932EncodeTest {34public static void main(String[] args) throws Exception {3536char[] testChars = new char[1];37byte[] testBytes = new byte[1];38int offset = 0;39String encoding = "windows-31j";4041// Halfwidth Katakana chars run from U+FF61 --> U+FF9F42// and their native equivalents in Code page 932 run43// sequentially from 0xa1 --> 0xdf4445for (int lsByte = 0x61 ; lsByte <= 0x9F; lsByte++, offset++) {46testChars[0] = (char) (lsByte | 0xFF00);47String s = new String(testChars);48testBytes = s.getBytes(encoding);49if ( testBytes[0] != (byte)(0xa1 + offset))50throw new Exception("failed Test");51}52}53}545556