author | jwilhelm |
Thu, 03 Oct 2019 07:10:36 +0200 | |
changeset 58449 | e606e9b6ba7a |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
5167
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
1 |
/* |
7668 | 2 |
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. |
5167
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
4 |
* |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
5167
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
5167
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
10 |
* |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
15 |
* accompanied this code). |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
16 |
* |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
20 |
* |
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
5167
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
24 |
*/ |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
25 |
|
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
26 |
package sun.nio.cs.ext; |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
27 |
|
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
28 |
import java.nio.charset.Charset; |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
29 |
import java.nio.charset.CharsetDecoder; |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
30 |
import java.nio.charset.CharsetEncoder; |
28969
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
31 |
import sun.nio.cs.DoubleByte; |
5167
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
32 |
import sun.nio.cs.HistoricallyNamedCharset; |
28969
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
33 |
import sun.nio.cs.*; |
5167
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
34 |
|
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
35 |
public class Big5_HKSCS_2001 extends Charset |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
36 |
{ |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
37 |
public Big5_HKSCS_2001() { |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
38 |
super("x-Big5-HKSCS-2001", ExtendedCharsets.aliasesFor("x-Big5-HKSCS-2001")); |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
39 |
} |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
40 |
|
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
41 |
public boolean contains(Charset cs) { |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
42 |
return ((cs.name().equals("US-ASCII")) |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
43 |
|| (cs instanceof Big5) |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
44 |
|| (cs instanceof Big5_HKSCS_2001)); |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
45 |
} |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
46 |
|
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
47 |
public CharsetDecoder newDecoder() { |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
48 |
return new Decoder(this); |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
49 |
} |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
50 |
|
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
51 |
public CharsetEncoder newEncoder() { |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
52 |
return new Encoder(this); |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
53 |
} |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
54 |
|
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
55 |
private static class Decoder extends HKSCS.Decoder { |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
56 |
private static DoubleByte.Decoder big5 = |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
57 |
(DoubleByte.Decoder)new Big5().newDecoder(); |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
58 |
|
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
59 |
private static char[][] b2cBmp = new char[0x100][]; |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
60 |
private static char[][] b2cSupp = new char[0x100][]; |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
61 |
static { |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
62 |
initb2c(b2cBmp, HKSCS2001Mapping.b2cBmpStr); |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
63 |
initb2c(b2cSupp, HKSCS2001Mapping.b2cSuppStr); |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
64 |
} |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
65 |
|
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
66 |
private Decoder(Charset cs) { |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
67 |
super(cs, big5, b2cBmp, b2cSupp); |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
68 |
} |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
69 |
} |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
70 |
|
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
71 |
private static class Encoder extends HKSCS.Encoder { |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
72 |
private static DoubleByte.Encoder big5 = |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
73 |
(DoubleByte.Encoder)new Big5().newEncoder(); |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
74 |
|
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
75 |
static char[][] c2bBmp = new char[0x100][]; |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
76 |
static char[][] c2bSupp = new char[0x100][]; |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
77 |
static { |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
78 |
initc2b(c2bBmp, HKSCS2001Mapping.b2cBmpStr, |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
79 |
HKSCS2001Mapping.pua); |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
80 |
initc2b(c2bSupp, HKSCS2001Mapping.b2cSuppStr, null); |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
81 |
} |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
82 |
|
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
83 |
private Encoder(Charset cs) { |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
84 |
super(cs, big5, c2bBmp, c2bSupp); |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
85 |
} |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
86 |
} |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
diff
changeset
|
87 |
} |