Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/nio/cs/ext/IBM942C.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;32import static sun.nio.cs.CharsetMapping.*;3334public class IBM942C extends Charset implements HistoricallyNamedCharset35{36public IBM942C() {37super("x-IBM942C", ExtendedCharsets.aliasesFor("x-IBM942C"));38}3940public String historicalName() {41return "Cp942C";42}4344public boolean contains(Charset cs) {45return ((cs.name().equals("US-ASCII"))46|| (cs instanceof IBM942C));47}4849public CharsetDecoder newDecoder() {50return new DoubleByte.Decoder(this,51IBM942.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 {66IBM942.initb2c();6768// the mappings need udpate are69// u+001a <-> 0x1a70// u+001c <-> 0x1c71// u+005c <-> 0x5c72// u+007e <-> 0x7e73// u+007f <-> 0x7f7475b2cSB = Arrays.copyOf(IBM942.b2cSB, IBM942.b2cSB.length);76b2cSB[0x1a] = 0x1a;77b2cSB[0x1c] = 0x1c;78b2cSB[0x5c] = 0x5c;79b2cSB[0x7e] = 0x7e;80b2cSB[0x7f] = 0x7f;8182IBM942.initc2b();83c2b = Arrays.copyOf(IBM942.c2b, IBM942.c2b.length);84c2bIndex = Arrays.copyOf(IBM942.c2bIndex, IBM942.c2bIndex.length);85c2b[c2bIndex[0] + 0x1a] = 0x1a;86c2b[c2bIndex[0] + 0x1c] = 0x1c;87c2b[c2bIndex[0] + 0x5c] = 0x5c;88c2b[c2bIndex[0] + 0x7e] = 0x7e;89c2b[c2bIndex[0] + 0x7f] = 0x7f;90}91}929394