Path: blob/master/test/jdk/sun/nio/cs/OLD/IBM942C_OLD.java
41154 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*/2425/*26*/2728import java.nio.charset.Charset;29import java.nio.charset.CharsetDecoder;30import java.nio.charset.CharsetEncoder;31import java.nio.charset.CharacterCodingException;32import sun.nio.cs.HistoricallyNamedCharset;3334public class IBM942C_OLD extends Charset implements HistoricallyNamedCharset35{3637public IBM942C_OLD() {38super("x-IBM942C_OLD", null);39}4041public String historicalName() {42return "Cp942C";43}4445public boolean contains(Charset cs) {46return ((cs.name().equals("US-ASCII"))47|| (cs instanceof IBM942C_OLD));48}4950public CharsetDecoder newDecoder() {51return new Decoder(this);52}5354public CharsetEncoder newEncoder() {55return new Encoder(this);56}5758private static class Decoder extends IBM942_OLD.Decoder {59protected static final String singleByteToChar;6061static {62String indexs = "";63for (char c = '\0'; c < '\u0080'; ++c) indexs += c;64singleByteToChar = indexs +65IBM942_OLD.Decoder.singleByteToChar.substring(indexs.length());66}6768public Decoder(Charset cs) {69super(cs, singleByteToChar);70}71}7273private static class Encoder extends IBM942_OLD.Encoder {7475protected static final short index1[];76protected static final String index2a;77protected static final int shift = 5;7879static {8081String indexs = "";82for (char c = '\0'; c < '\u0080'; ++c) indexs += c;83index2a = IBM942_OLD.Encoder.index2a + indexs;84int o = IBM942_OLD.Encoder.index2a.length() + 15000;85index1 = new short[IBM942_OLD.Encoder.index1.length];868788System.arraycopy(IBM942_OLD.Encoder.index1,890,90index1,910,92IBM942_OLD.Encoder.index1.length);9394for (int i = 0; i * (1<<shift) < 128; ++i) {95index1[i] = (short)(o + i * (1<<shift));96}97}9899public Encoder(Charset cs) {100super(cs, index1, index2a);101}102}103}104105106