author | lmesnik |
Mon, 27 Aug 2018 12:45:31 -0700 | |
changeset 51536 | f23312250f25 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
28969
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
1 |
/* |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
2 |
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
4 |
* |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
10 |
* |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
15 |
* accompanied this code). |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
16 |
* |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
20 |
* |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
23 |
* questions. |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
24 |
*/ |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
25 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
26 |
package $PACKAGE$; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
27 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
28 |
import java.nio.ByteBuffer; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
29 |
import java.nio.CharBuffer; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
30 |
import java.nio.charset.Charset; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
31 |
import java.nio.charset.CharsetDecoder; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
32 |
import java.nio.charset.CharsetEncoder; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
33 |
import java.nio.charset.CoderResult; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
34 |
import sun.nio.cs.DoubleByte; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
35 |
import sun.nio.cs.HistoricallyNamedCharset; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
36 |
import sun.nio.cs.*; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
37 |
import static sun.nio.cs.CharsetMapping.*; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
38 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
39 |
public class EUC_JP_Open |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
40 |
extends Charset |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
41 |
implements HistoricallyNamedCharset |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
42 |
{ |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
43 |
public EUC_JP_Open() { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
44 |
super("x-eucJP-Open", $ALIASES$); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
45 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
46 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
47 |
public String historicalName() { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
48 |
return "EUC_JP_Solaris"; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
49 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
50 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
51 |
public boolean contains(Charset cs) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
52 |
return ((cs.name().equals("US-ASCII")) |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
53 |
|| (cs instanceof JIS_X_0201) |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
54 |
|| (cs instanceof EUC_JP)); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
55 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
56 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
57 |
public CharsetDecoder newDecoder() { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
58 |
return new Decoder(this); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
59 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
60 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
61 |
public CharsetEncoder newEncoder() { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
62 |
return new Encoder(this); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
63 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
64 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
65 |
private static class Decoder extends EUC_JP.Decoder { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
66 |
private static DoubleByte.Decoder DEC0208_Solaris = |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
67 |
(DoubleByte.Decoder)new JIS_X_0208_Solaris().newDecoder(); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
68 |
private static DoubleByte.Decoder DEC0212_Solaris = |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
69 |
(DoubleByte.Decoder)new JIS_X_0212_Solaris().newDecoder(); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
70 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
71 |
private Decoder(Charset cs) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
72 |
// JIS_X_0208_Solaris only has the "extra" mappings, it |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
73 |
// does not have the JIS_X_0208 entries |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
74 |
super(cs, 0.5f, 1.0f, DEC0201, DEC0208, DEC0212_Solaris); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
75 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
76 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
77 |
protected char decodeDouble(int byte1, int byte2) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
78 |
char c = super.decodeDouble(byte1, byte2); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
79 |
if (c == UNMAPPABLE_DECODING) |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
80 |
return DEC0208_Solaris.decodeDouble(byte1 - 0x80, byte2 - 0x80); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
81 |
return c; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
82 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
83 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
84 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
85 |
private static class Encoder extends EUC_JP.Encoder { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
86 |
private static DoubleByte.Encoder ENC0208_Solaris = |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
87 |
(DoubleByte.Encoder)new JIS_X_0208_Solaris().newEncoder(); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
88 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
89 |
private static DoubleByte.Encoder ENC0212_Solaris = |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
90 |
(DoubleByte.Encoder)new JIS_X_0212_Solaris().newEncoder(); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
91 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
92 |
private Encoder(Charset cs) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
93 |
// The EUC_JP_Open has some interesting tweak for the |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
94 |
// encoding, so can't just pass the euc0208_solaris to |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
95 |
// the euc_jp. Have to override the encodeDouble() as |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
96 |
// showed below (mapping testing catches this). |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
97 |
// super(cs, 3.0f, 3.0f, ENC0201, ENC0208_Solaris, ENC0212_Solaris); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
98 |
super(cs); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
99 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
100 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
101 |
protected int encodeDouble(char ch) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
102 |
int b = super.encodeDouble(ch); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
103 |
if (b != UNMAPPABLE_ENCODING) |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
104 |
return b; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
105 |
b = ENC0208_Solaris.encodeChar(ch); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
106 |
if (b != UNMAPPABLE_ENCODING && b > 0x7500) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
107 |
return 0x8F8080 + ENC0212_Solaris.encodeChar(ch); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
108 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
109 |
return b == UNMAPPABLE_ENCODING ? b : b + 0x8080; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
110 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
111 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
112 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff
changeset
|
113 |
} |