Path: blob/master/test/jdk/sun/nio/cs/HWKatakanaMS932EncodeTest.java
41152 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* @modules jdk.charsets27*/2829/*30* Tests encodeability of the Unicode defined Halfwidth Katakana31* characters using the MS932/windows-31j encoder32*/3334public class HWKatakanaMS932EncodeTest {35public static void main(String[] args) throws Exception {3637char[] testChars = new char[1];38byte[] testBytes = new byte[1];39int offset = 0;40String encoding = "windows-31j";4142// Halfwidth Katakana chars run from U+FF61 --> U+FF9F43// and their native equivalents in Code page 932 run44// sequentially from 0xa1 --> 0xdf4546for (int lsByte = 0x61 ; lsByte <= 0x9F; lsByte++, offset++) {47testChars[0] = (char) (lsByte | 0xFF00);48String s = new String(testChars);49testBytes = s.getBytes(encoding);50if ( testBytes[0] != (byte)(0xa1 + offset))51throw new Exception("failed Test");52}53}54}555657