2246N/A/*
3261N/A * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
2246N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2246N/A *
2246N/A * This code is free software; you can redistribute it and/or modify it
2246N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
2246N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
2246N/A *
2246N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2246N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2246N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2246N/A * version 2 for more details (a copy is included in the LICENSE file that
2246N/A * accompanied this code).
2246N/A *
2246N/A * You should have received a copy of the GNU General Public License version
2246N/A * 2 along with this work; if not, write to the Free Software Foundation,
2246N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2246N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
2246N/A */
2246N/A
2246N/Apackage sun.nio.cs.ext;
2246N/A
2246N/Aimport java.nio.charset.Charset;
2246N/Aimport java.nio.charset.CharsetDecoder;
2246N/Aimport java.nio.charset.CharsetEncoder;
2246N/Aimport sun.nio.cs.HistoricallyNamedCharset;
2246N/Aimport static sun.nio.cs.CharsetMapping.*;
2246N/A
2246N/Apublic class MS950_HKSCS_XP extends Charset
2246N/A{
2246N/A public MS950_HKSCS_XP() {
2246N/A super("x-MS950-HKSCS-XP", ExtendedCharsets.aliasesFor("x-MS950-HKSCS-XP"));
2246N/A }
2246N/A
2246N/A public boolean contains(Charset cs) {
2246N/A return ((cs.name().equals("US-ASCII"))
2246N/A || (cs instanceof MS950)
2246N/A || (cs instanceof MS950_HKSCS_XP));
2246N/A }
2246N/A
2246N/A public CharsetDecoder newDecoder() {
2246N/A return new Decoder(this);
2246N/A }
2246N/A
2246N/A public CharsetEncoder newEncoder() {
2246N/A return new Encoder(this);
2246N/A }
2246N/A
2246N/A static class Decoder extends HKSCS.Decoder {
2246N/A private static DoubleByte.Decoder ms950 =
2246N/A (DoubleByte.Decoder)new MS950().newDecoder();
2246N/A
2246N/A /*
2246N/A * Note current decoder decodes 0x8BC2 --> U+F53A
2246N/A * ie. maps to Unicode PUA.
2246N/A * Unaccounted discrepancy between this mapping
2246N/A * inferred from MS950/windows-950 and the published
2246N/A * MS HKSCS mappings which maps 0x8BC2 --> U+5C22
2246N/A * a character defined with the Unified CJK block
2246N/A */
2246N/A private static char[][] b2cBmp = new char[0x100][];
2246N/A static {
2246N/A initb2c(b2cBmp, HKSCS_XPMapping.b2cBmpStr);
2246N/A }
2246N/A
2246N/A public char decodeDoubleEx(int b1, int b2) {
2246N/A return UNMAPPABLE_DECODING;
2246N/A }
2246N/A
2246N/A private Decoder(Charset cs) {
2246N/A super(cs, ms950, b2cBmp, null);
2246N/A }
2246N/A }
2246N/A
2246N/A private static class Encoder extends HKSCS.Encoder {
2246N/A private static DoubleByte.Encoder ms950 =
2246N/A (DoubleByte.Encoder)new MS950().newEncoder();
2246N/A
2246N/A /*
2246N/A * Note current encoder encodes U+F53A --> 0x8BC2
2246N/A * Published MS HKSCS mappings show
2246N/A * U+5C22 <--> 0x8BC2
2246N/A */
2246N/A static char[][] c2bBmp = new char[0x100][];
2246N/A static {
2246N/A initc2b(c2bBmp, HKSCS_XPMapping.b2cBmpStr, null);
2246N/A }
2246N/A
2246N/A public int encodeSupp(int cp) {
2246N/A return UNMAPPABLE_ENCODING;
2246N/A }
2246N/A
2246N/A private Encoder(Charset cs) {
2246N/A super(cs, ms950, c2bBmp, null);
2246N/A }
2246N/A }
2246N/A}