Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/nio/cs/ext/IBM943C.java
38919 views
/*1* Copyright (c) 2003, 2004, 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. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.nio.cs.ext;2627import java.nio.charset.Charset;28import java.nio.charset.CharsetDecoder;29import java.nio.charset.CharsetEncoder;30import java.util.Arrays;31import sun.nio.cs.HistoricallyNamedCharset;3233public class IBM943C extends Charset implements HistoricallyNamedCharset34{3536public IBM943C() {37super("x-IBM943C", ExtendedCharsets.aliasesFor("x-IBM943C"));38}3940public String historicalName() {41return "Cp943C";42}4344public boolean contains(Charset cs) {45return ((cs.name().equals("US-ASCII"))46|| (cs instanceof IBM943C));47}4849public CharsetDecoder newDecoder() {50return new DoubleByte.Decoder(this,51IBM943.b2c,52b2cSB,530x40,540xfc);55}5657public CharsetEncoder newEncoder() {58return new DoubleByte.Encoder(this, c2b, c2bIndex);59}6061final static char[] b2cSB;62final static char[] c2b;63final static char[] c2bIndex;6465static {66IBM943.initb2c();67b2cSB = new char[0x100];68for (int i = 0; i < 0x80; i++) {69b2cSB[i] = (char)i;70}71for (int i = 0x80; i < 0x100; i++) {72b2cSB[i] = IBM943.b2cSB[i];73}7475IBM943.initc2b();76c2b = Arrays.copyOf(IBM943.c2b, IBM943.c2b.length);77c2bIndex = Arrays.copyOf(IBM943.c2bIndex, IBM943.c2bIndex.length);78for (char c = '\0'; c < '\u0080'; ++c) {79int index = c2bIndex[c >> 8];80c2b[index + (c & 0xff)] = c;81}82}83}848586