Path: blob/master/test/jdk/sun/nio/cs/OLD/IBM943C_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*/272829import java.nio.charset.Charset;30import java.nio.charset.CharsetDecoder;31import java.nio.charset.CharsetEncoder;32import java.nio.charset.CharacterCodingException;33import sun.nio.cs.HistoricallyNamedCharset;3435public class IBM943C_OLD extends Charset implements HistoricallyNamedCharset36{3738public IBM943C_OLD() {39super("x-IBM943C_OLD", null);40}4142public String historicalName() {43return "Cp943_OLDC";44}4546public boolean contains(Charset cs) {47return ((cs.name().equals("US-ASCII"))48|| (cs instanceof IBM943C_OLD));49}5051public CharsetDecoder newDecoder() {52return new Decoder(this);53}5455public CharsetEncoder newEncoder() {56return new Encoder(this);57}5859private static class Decoder extends IBM943_OLD.Decoder {60protected static final String singleByteToChar;6162static {63String indexs = "";64for (char c = '\0'; c < '\u0080'; ++c) indexs += c;65singleByteToChar = indexs +66IBM943_OLD.Decoder.singleByteToChar.substring(indexs.length());67}6869public Decoder(Charset cs) {70super(cs, singleByteToChar);71}72}7374private static class Encoder extends IBM943_OLD.Encoder {7576protected static final short index1[];77protected static final String index2a;78protected static final int shift = 6;7980static {81String indexs = "";82for (char c = '\0'; c < '\u0080'; ++c) indexs += c;83index2a = IBM943_OLD.Encoder.index2a + indexs;8485int o = IBM943_OLD.Encoder.index2a.length() + 15000;86index1 = new short[IBM943_OLD.Encoder.index1.length];87System.arraycopy(IBM943_OLD.Encoder.index1,880,89index1,900,91IBM943_OLD.Encoder.index1.length);9293for (int i = 0; i * (1<<shift) < 128; ++i) {94index1[i] = (short)(o + i * (1<<shift));95}96}9798public Encoder(Charset cs) {99super(cs, index1, index2a);100}101}102}103104105