author | mgronlun |
Mon, 09 Sep 2019 13:26:35 +0200 | |
branch | JEP-349-branch |
changeset 58049 | 10ecdb5d3574 |
parent 53474 | 1262a93634c2 |
permissions | -rw-r--r-- |
53474
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
1 |
/* |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
2 |
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
4 |
* |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
10 |
* |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
15 |
* accompanied this code). |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
16 |
* |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
20 |
* |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
23 |
* questions. |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
24 |
*/ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
25 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
26 |
package $PACKAGE$; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
27 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
28 |
import java.nio.ByteBuffer; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
29 |
import java.nio.CharBuffer; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
30 |
import java.nio.charset.Charset; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
31 |
import java.nio.charset.CharsetDecoder; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
32 |
import java.nio.charset.CharsetEncoder; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
33 |
import java.nio.charset.CoderResult; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
34 |
import sun.nio.cs.HistoricallyNamedCharset; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
35 |
import sun.nio.cs.DelegatableDecoder; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
36 |
import sun.nio.cs.DoubleByte; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
37 |
import sun.nio.cs.Surrogate; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
38 |
import sun.nio.cs.SingleByte; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
39 |
import sun.nio.cs.*; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
40 |
import static sun.nio.cs.CharsetMapping.*; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
41 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
42 |
public class IBM29626C |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
43 |
extends Charset |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
44 |
implements HistoricallyNamedCharset |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
45 |
{ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
46 |
public IBM29626C() { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
47 |
super("x-IBM29626C", $ALIASES$); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
48 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
49 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
50 |
public String historicalName() { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
51 |
return "Cp29626C"; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
52 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
53 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
54 |
public boolean contains(Charset cs) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
55 |
return ((cs.name().equals("US-ASCII")) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
56 |
|| (cs instanceof IBM29626C)); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
57 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
58 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
59 |
public CharsetDecoder newDecoder() { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
60 |
return new Decoder(this); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
61 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
62 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
63 |
public CharsetEncoder newEncoder() { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
64 |
return new Encoder(this); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
65 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
66 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
67 |
static class Decoder extends CharsetDecoder |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
68 |
implements DelegatableDecoder { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
69 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
70 |
final static SingleByte.Decoder DEC0201 = |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
71 |
(SingleByte.Decoder)new JIS_X_0201().newDecoder(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
72 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
73 |
final static DoubleByte.Decoder DEC0208 = |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
74 |
(DoubleByte.Decoder)new JIS_X_0208().newDecoder(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
75 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
76 |
final static DoubleByte.Decoder DEC0212 = |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
77 |
(DoubleByte.Decoder)new JIS_X_0212().newDecoder(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
78 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
79 |
final static DoubleByte.Encoder ibm943 = |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
80 |
(DoubleByte.Encoder)new IBM943().newEncoder(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
81 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
82 |
private final SingleByte.Decoder dec0201; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
83 |
private final DoubleByte.Decoder dec0208; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
84 |
private final DoubleByte.Decoder dec0212; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
85 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
86 |
private final String G2_b = |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
87 |
"\uA1F1\uA1F2\uA2CC\uADA1\uADA2\uADA3\uADA4\uADA5\uADA6\uADA7"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
88 |
"\uADA8\uADA9\uADAA\uADAB\uADAC\uADAD\uADAE\uADAF\uADB0\uADB1"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
89 |
"\uADB2\uADB3\uADB4\uADB5\uADB6\uADB7\uADB8\uADB9\uADBA\uADBB"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
90 |
"\uADBC\uADBD\uADBE\uADC0\uADC1\uADC2\uADC3\uADC4\uADC5\uADC6"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
91 |
"\uADC7\uADC8\uADC9\uADCA\uADCB\uADCC\uADCD\uADCE\uADCF\uADD0"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
92 |
"\uADD1\uADD2\uADD3\uADD4\uADD5\uADD6\uADDF\uADE0\uADE1\uADE2"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
93 |
"\uADE3\uADE4\uADE5\uADE6\uADE7\uADE8\uADE9\uADEA\uADEB\uADEC"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
94 |
"\uADED\uADEE\uADEF\uADF0\uADF1\uADF2\uADF3\uADF4\uADF5\uADF6"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
95 |
"\uADF7\uADF8\uADF9\uADFA\uADFB\uADFC"; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
96 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
97 |
private final String G2_c = |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
98 |
"\uFFE0\uFFE1\uFFE2\u2460\u2461\u2462\u2463\u2464\u2465\u2466"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
99 |
"\u2467\u2468\u2469\u246A\u246B\u246C\u246D\u246E\u246F\u2470"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
100 |
"\u2471\u2472\u2473\u2160\u2161\u2162\u2163\u2164\u2165\u2166"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
101 |
"\u2167\u2168\u2169\u3349\u3314\u3322\u334D\u3318\u3327\u3303"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
102 |
"\u3336\u3351\u3357\u330D\u3326\u3323\u332B\u334A\u333B\u339C"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
103 |
"\u339D\u339E\u338E\u338F\u33C4\u33A1\u337B\u301D\u301F\u2116"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
104 |
"\u33CD\u2121\u32A4\u32A5\u32A6\u32A7\u32A8\u3231\u3232\u3239"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
105 |
"\u337E\u337D\u337C\u2252\u2261\u222B\u222E\u2211\u221A\u22A5"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
106 |
"\u2220\u221F\u22BF\u2235\u2229\u222A"; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
107 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
108 |
private final String G3_b = |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
109 |
"\uF3B8\uF3B9\uF3AB\uF3AC\uF3AD\uF3AE\uF3AF\uF3B0\uF3B1\uF3B2"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
110 |
"\uF3B3\uF3B4\uF3A1\uF3A2\uF3A3\uF3A4\uF3A5\uF3A6\uF3A7\uF3A8"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
111 |
"\uF3A9\uF3AA\uF3B7\uF3B8\uF4A2\uF4A3\uF4A4\uF4A5\uF4A6\uF4A8"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
112 |
"\uF4A9\uF4AC\uF4AE\uF4AF\uF4B0\uF4B2\uF4B3\uF4B4\uF4B5\uF4B6"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
113 |
"\uF4B7\uF4BA\uF4BD\uF4BE\uF4C0\uF4BF\uF4C2\uF4A1\uF4C6\uF4C7"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
114 |
"\uF4C8\uF4CB\uF4D0\uF4D4\uF4D5\uF4D7\uF4D9\uF4DC\uF4DF\uF4E0"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
115 |
"\uF4E1\uF4E5\uF4E7\uF4EA\uF4ED\uF4EE\uF4EF\uF4F4\uF4F5\uF4F6"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
116 |
"\uF4F8\uF3B8\uF4B9\uF4EB\uF4A7\uF4AA\uF4AB\uF4B1\uF4B8\uF4BB"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
117 |
"\uF4BC\uF4C4\uF4C5\uF4C9\uF4CC\uF4CD\uF4CE\uF4CF\uF4D1\uF4D3"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
118 |
"\uF4D6\uF4D8\uF4DA\uF4DB\uF4DE\uF4E2\uF4E3\uF4E4\uF4E6\uF4E8"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
119 |
"\uF4E9\uF4EC\uF4F1\uF4F2\uF4F3\uF4F7\uF3B6\uF3B5"; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
120 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
121 |
private final String G3_c = |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
122 |
"\u2116\u2121\u2160\u2161\u2162\u2163\u2164\u2165\u2166\u2167"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
123 |
"\u2168\u2169\u2170\u2171\u2172\u2173\u2174\u2175\u2176\u2177"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
124 |
"\u2178\u2179\u3231\u00A6\u4EFC\u50F4\u51EC\u5307\u5324\u548A"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
125 |
"\u5759\u589E\u5BEC\u5CF5\u5D53\u5FB7\u6085\u6120\u654E\u663B"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
126 |
"\u6665\u6801\u6A6B\u6AE2\u6DF2\u6DF8\u7028\u70BB\u7501\u7682"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
127 |
"\u769E\u7930\u7AE7\u7DA0\u7DD6\u8362\u85B0\u8807\u8B7F\u8CF4"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
128 |
"\u8D76\u90DE\u9115\u9592\u973B\u974D\u9751\u999E\u9AD9\u9B72"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
129 |
"\u9ED1\uF86F\uF929\uF9DC\uFA0E\uFA0F\uFA10\uFA11\uFA12\uFA13"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
130 |
"\uFA14\uFA15\uFA16\uFA17\uFA18\uFA19\uFA1A\uFA1B\uFA1C\uFA1D"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
131 |
"\uFA1E\uFA1F\uFA20\uFA21\uFA22\uFA23\uFA24\uFA25\uFA26\uFA27"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
132 |
"\uFA28\uFA29\uFA2A\uFA2B\uFA2C\uFA2D\uFF02\uFF07"; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
133 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
134 |
protected Decoder(Charset cs) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
135 |
this(cs, 0.5f, 1.0f, DEC0201, DEC0208, DEC0212); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
136 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
137 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
138 |
protected Decoder(Charset cs, float avgCpb, float maxCpb, |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
139 |
SingleByte.Decoder dec0201, |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
140 |
DoubleByte.Decoder dec0208, |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
141 |
DoubleByte.Decoder dec0212) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
142 |
super(cs, avgCpb, maxCpb); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
143 |
this.dec0201 = dec0201; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
144 |
this.dec0208 = dec0208; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
145 |
this.dec0212 = dec0212; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
146 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
147 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
148 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
149 |
protected char decodeSingle(int b) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
150 |
if (b < 0x8e) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
151 |
return (char) b; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
152 |
if (b < 0x90) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
153 |
return UNMAPPABLE_DECODING; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
154 |
if (b < 0xa0) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
155 |
return (char) b; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
156 |
return UNMAPPABLE_DECODING; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
157 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
158 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
159 |
protected char decodeUDC(int byte1, int byte2, int offset) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
160 |
if ((byte1 >= 0xf5 && byte1 <= 0xfe) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
161 |
&& (byte2 >= 0xa1 && byte2 <= 0xfe)) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
162 |
return (char)((byte1 - 0xf5) * 94 + (byte2 - 0xa1) + offset); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
163 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
164 |
return UNMAPPABLE_DECODING; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
165 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
166 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
167 |
final static String g1_c = "\u00a2\u00a3\u00ac\\\u007e"; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
168 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
169 |
protected char decodeDouble(int byte1, int byte2) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
170 |
if (byte1 == 0x8e) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
171 |
if (byte2 < 0x80) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
172 |
return UNMAPPABLE_DECODING; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
173 |
char c = dec0201.decode((byte)byte2); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
174 |
if (byte2 >= 0xe0 && byte2 <= 0xe4) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
175 |
c = g1_c.charAt(byte2 - 0xe0); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
176 |
return c; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
177 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
178 |
if ((byte1 >= 0xa1 && byte1 <= 0xfe) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
179 |
&& (byte2 >= 0xa1 && byte2 <= 0xfe)) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
180 |
char c = (char)((byte1 << 8) + byte2); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
181 |
int idx = G2_b.indexOf(c); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
182 |
if (idx > -1) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
183 |
return G2_c.charAt(idx); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
184 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
185 |
char ch = dec0208.decodeDouble(byte1 - 0x80, byte2 - 0x80); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
186 |
if (ch == UNMAPPABLE_DECODING) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
187 |
ch = decodeUDC(byte1, byte2, 0xe000); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
188 |
return ch; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
189 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
190 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
191 |
protected char decodeDoubleG3(int byte1, int byte2) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
192 |
if ((byte1 >= 0xa1 && byte1 <= 0xfe) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
193 |
&& (byte2 >= 0xa1 && byte2 <= 0xfe)) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
194 |
char c = (char)((byte1 << 8) + byte2); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
195 |
int idx = G3_b.indexOf(c); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
196 |
if (idx > -1) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
197 |
return G3_c.charAt(idx); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
198 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
199 |
char ch = dec0212.decodeDouble(byte1 - 0x80, byte2 - 0x80); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
200 |
if (ch == '\u2116') |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
201 |
ch = UNMAPPABLE_DECODING; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
202 |
if (ch != UNMAPPABLE_DECODING) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
203 |
ch = ibm943.canEncode(ch) ? ch : UNMAPPABLE_DECODING; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
204 |
if (ch == UNMAPPABLE_DECODING) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
205 |
ch = decodeUDC(byte1, byte2, 0xe3ac); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
206 |
return ch; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
207 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
208 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
209 |
private CoderResult decodeArrayLoop(ByteBuffer src, |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
210 |
CharBuffer dst) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
211 |
{ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
212 |
byte[] sa = src.array(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
213 |
int sp = src.arrayOffset() + src.position(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
214 |
int sl = src.arrayOffset() + src.limit(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
215 |
assert (sp <= sl); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
216 |
sp = (sp <= sl ? sp : sl); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
217 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
218 |
char[] da = dst.array(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
219 |
int dp = dst.arrayOffset() + dst.position(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
220 |
int dl = dst.arrayOffset() + dst.limit(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
221 |
assert (dp <= dl); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
222 |
dp = (dp <= dl ? dp : dl); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
223 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
224 |
int b1 = 0, b2 = 0; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
225 |
int inputSize = 0; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
226 |
char outputChar = UNMAPPABLE_DECODING; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
227 |
try { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
228 |
while (sp < sl) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
229 |
b1 = sa[sp] & 0xff; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
230 |
inputSize = 1; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
231 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
232 |
outputChar = decodeSingle(b1); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
233 |
if (outputChar == UNMAPPABLE_DECODING) { // Multibyte char |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
234 |
if (b1 == 0x8f) { // JIS0212 |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
235 |
if (sp + 3 > sl) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
236 |
return CoderResult.UNDERFLOW; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
237 |
b1 = sa[sp + 1] & 0xff; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
238 |
b2 = sa[sp + 2] & 0xff; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
239 |
inputSize += 2; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
240 |
outputChar = decodeDoubleG3(b1, b2); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
241 |
} else { // JIS0201, JIS0208 |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
242 |
if (sp + 2 > sl) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
243 |
return CoderResult.UNDERFLOW; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
244 |
b2 = sa[sp + 1] & 0xff; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
245 |
inputSize++; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
246 |
outputChar = decodeDouble(b1, b2); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
247 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
248 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
249 |
if (outputChar == UNMAPPABLE_DECODING) { // can't be decoded |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
250 |
return CoderResult.unmappableForLength(inputSize); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
251 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
252 |
if (dp + 1 > dl) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
253 |
return CoderResult.OVERFLOW; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
254 |
da[dp++] = outputChar; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
255 |
sp += inputSize; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
256 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
257 |
return CoderResult.UNDERFLOW; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
258 |
} finally { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
259 |
src.position(sp - src.arrayOffset()); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
260 |
dst.position(dp - dst.arrayOffset()); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
261 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
262 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
263 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
264 |
private CoderResult decodeBufferLoop(ByteBuffer src, |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
265 |
CharBuffer dst) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
266 |
{ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
267 |
int mark = src.position(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
268 |
int b1 = 0, b2 = 0; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
269 |
int inputSize = 0; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
270 |
char outputChar = UNMAPPABLE_DECODING; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
271 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
272 |
try { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
273 |
while (src.hasRemaining()) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
274 |
b1 = src.get() & 0xff; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
275 |
inputSize = 1; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
276 |
outputChar = decodeSingle(b1); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
277 |
if (outputChar == UNMAPPABLE_DECODING) { // Multibyte char |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
278 |
if (b1 == 0x8f) { // JIS0212 |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
279 |
if (src.remaining() < 2) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
280 |
return CoderResult.UNDERFLOW; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
281 |
b1 = src.get() & 0xff; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
282 |
b2 = src.get() & 0xff; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
283 |
inputSize += 2; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
284 |
outputChar = decodeDoubleG3(b1, b2); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
285 |
} else { // JIS0201 JIS0208 |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
286 |
if (src.remaining() < 1) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
287 |
return CoderResult.UNDERFLOW; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
288 |
b2 = src.get() & 0xff; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
289 |
inputSize++; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
290 |
outputChar = decodeDouble(b1, b2); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
291 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
292 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
293 |
if (outputChar == UNMAPPABLE_DECODING) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
294 |
return CoderResult.unmappableForLength(inputSize); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
295 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
296 |
if (dst.remaining() < 1) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
297 |
return CoderResult.OVERFLOW; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
298 |
dst.put(outputChar); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
299 |
mark += inputSize; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
300 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
301 |
return CoderResult.UNDERFLOW; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
302 |
} finally { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
303 |
src.position(mark); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
304 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
305 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
306 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
307 |
// Make some protected methods public for use by JISAutoDetect |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
308 |
public CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
309 |
if (src.hasArray() && dst.hasArray()) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
310 |
return decodeArrayLoop(src, dst); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
311 |
else |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
312 |
return decodeBufferLoop(src, dst); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
313 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
314 |
public void implReset() { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
315 |
super.implReset(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
316 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
317 |
public CoderResult implFlush(CharBuffer out) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
318 |
return super.implFlush(out); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
319 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
320 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
321 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
322 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
323 |
static class Encoder extends CharsetEncoder { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
324 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
325 |
final static SingleByte.Encoder ENC0201 = |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
326 |
(SingleByte.Encoder)new JIS_X_0201().newEncoder(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
327 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
328 |
final static DoubleByte.Encoder ENC0208 = |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
329 |
(DoubleByte.Encoder)new JIS_X_0208().newEncoder(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
330 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
331 |
final static DoubleByte.Encoder ENC0212 = |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
332 |
(DoubleByte.Encoder)new JIS_X_0212().newEncoder(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
333 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
334 |
final static DoubleByte.Encoder ibm943 = |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
335 |
(DoubleByte.Encoder)new IBM943().newEncoder(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
336 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
337 |
private final Surrogate.Parser sgp = new Surrogate.Parser(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
338 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
339 |
private final SingleByte.Encoder enc0201; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
340 |
private final DoubleByte.Encoder enc0208; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
341 |
private final DoubleByte.Encoder enc0212; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
342 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
343 |
private final String G2_c = |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
344 |
"\u2015\u2211\u221F\u2225\u222E\u22BF\u2460\u2461\u2462\u2463"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
345 |
"\u2464\u2465\u2466\u2467\u2468\u2469\u246A\u246B\u246C\u246D"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
346 |
"\u246E\u246F\u2470\u2471\u2472\u2473\u301D\u301F\u3232\u3239"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
347 |
"\u32A4\u32A5\u32A6\u32A7\u32A8\u3303\u330D\u3314\u3318\u3322"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
348 |
"\u3323\u3326\u3327\u332B\u3336\u333B\u3349\u334A\u334D\u3351"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
349 |
"\u3357\u337B\u337C\u337D\u337E\u338E\u338F\u339C\u339D\u339E"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
350 |
"\u33A1\u33C4\u33CD\u4FE0\u525D\u555E\u5699\u56CA\u5861\u5C5B"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
351 |
"\u5C62\u6414\u6451\u6522\u6805\u688E\u6F51\u7006\u7130\u7626"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
352 |
"\u79B1\u7C1E\u7E48\u7E61\u7E6B\u8141\u8346\u840A\u8523\u87EC"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
353 |
"\u881F\u8EC0\u91AC\u91B1\u9830\u9839\u985A\u9A52\u9DD7\u9E7C"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
354 |
"\u9EB4\u9EB5\uFF0D\uFF5E\uFFE0\uFFE1\uFFE2"; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
355 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
356 |
private final String G2_b = |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
357 |
"\uA1BD\uADF4\uADF8\uA1C2\uADF3\uADF9\uADA1\uADA2\uADA3\uADA4"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
358 |
"\uADA5\uADA6\uADA7\uADA8\uADA9\uADAA\uADAB\uADAC\uADAD\uADAE"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
359 |
"\uADAF\uADB0\uADB1\uADB2\uADB3\uADB4\uADE0\uADE1\uADEB\uADEC"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
360 |
"\uADE5\uADE6\uADE7\uADE8\uADE9\uADC6\uADCA\uADC1\uADC4\uADC2"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
361 |
"\uADCC\uADCB\uADC5\uADCD\uADC7\uADCF\uADC0\uADCE\uADC3\uADC8"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
362 |
"\uADC9\uADDF\uADEF\uADEE\uADED\uADD3\uADD4\uADD0\uADD1\uADD2"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
363 |
"\uADD6\uADD5\uADE3\uB6A2\uC7ED\uB0A2\uB3FA\uC7B9\uC5B6\uD6A2"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
364 |
"\uBCC8\uC1DF\uC4CF\uDAB9\uBAF4\uDBF4\uC8AE\uC6C2\uB1EB\uC1E9"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
365 |
"\uC5F8\uC3BD\uE5DA\uBDAB\uB7D2\uE7A6\uB7D5\uCDE9\uBED5\uC0E6"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
366 |
"\uCFB9\uB6ED\uBEDF\uC8B0\uCBCB\uF0F8\uC5BF\uC2CD\uB2AA\uB8B4"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
367 |
"\uB9ED\uCCCD\uA1DD\uA1C1\uA1F1\uA1F2\uA2CC"; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
368 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
369 |
private final String G3_c = |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
370 |
"\u2116\u2121\u2160\u2161\u2162\u2163\u2164\u2165\u2166\u2167"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
371 |
"\u2168\u2169\u2170\u2171\u2172\u2173\u2174\u2175\u2176\u2177"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
372 |
"\u2178\u2179\u3231\u4EFC\u50F4\u51EC\u5307\u5324\u548A\u5759"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
373 |
"\u589E\u5BEC\u5CF5\u5D53\u5FB7\u6085\u6120\u654E\u663B\u6665"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
374 |
"\u6801\u6A6B\u6AE2\u6DF2\u6DF8\u7028\u70BB\u7501\u7682\u769E"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
375 |
"\u7930\u7AE7\u7DA0\u7DD6\u8362\u85B0\u8807\u8B7F\u8CF4\u8D76"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
376 |
"\u90DE\u9115\u9592\u973B\u974D\u9751\u999E\u9AD9\u9B72\u9ED1"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
377 |
"\uF86F\uF929\uF9DC\uFA0E\uFA0F\uFA10\uFA11\uFA12\uFA13\uFA14"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
378 |
"\uFA15\uFA16\uFA17\uFA18\uFA19\uFA1A\uFA1B\uFA1C\uFA1D\uFA1E"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
379 |
"\uFA1F\uFA20\uFA21\uFA22\uFA23\uFA24\uFA25\uFA26\uFA27\uFA28"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
380 |
"\uFA29\uFA2A\uFA2B\uFA2C\uFA2D\uFF02\uFF07\uFFE4"; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
381 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
382 |
private final String G3_b = |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
383 |
"\uF3B8\uF3B9\uF3AB\uF3AC\uF3AD\uF3AE\uF3AF\uF3B0\uF3B1\uF3B2"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
384 |
"\uF3B3\uF3B4\uF3A1\uF3A2\uF3A3\uF3A4\uF3A5\uF3A6\uF3A7\uF3A8"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
385 |
"\uF3A9\uF3AA\uF3B7\uF4A2\uF4A3\uF4A4\uF4A5\uF4A6\uF4A8\uF4A9"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
386 |
"\uF4AC\uF4AE\uF4AF\uF4B0\uF4B2\uF4B3\uF4B4\uF4B5\uF4B6\uF4B7"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
387 |
"\uF4BA\uF4BD\uF4BE\uF4C0\uF4BF\uF4C2\uF4A1\uF4C6\uF4C7\uF4C8"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
388 |
"\uF4CB\uF4D0\uF4D4\uF4D5\uF4D7\uF4D9\uF4DC\uF4DF\uF4E0\uF4E1"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
389 |
"\uF4E5\uF4E7\uF4EA\uF4ED\uF4EE\uF4EF\uF4F4\uF4F5\uF4F6\uF4F8"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
390 |
"\uF3B8\uF4B9\uF4EB\uF4A7\uF4AA\uF4AB\uF4B1\uF4B8\uF4BB\uF4BC"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
391 |
"\uF4C4\uF4C5\uF4C9\uF4CC\uF4CD\uF4CE\uF4CF\uF4D1\uF4D3\uF4D6"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
392 |
"\uF4D8\uF4DA\uF4DB\uF4DE\uF4E2\uF4E3\uF4E4\uF4E6\uF4E8\uF4E9"+ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
393 |
"\uF4EC\uF4F1\uF4F2\uF4F3\uF4F7\uF3B6\uF3B5\uA2C3"; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
394 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
395 |
protected Encoder(Charset cs) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
396 |
this(cs, 3.0f, 3.0f, ENC0201, ENC0208, ENC0212); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
397 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
398 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
399 |
protected Encoder(Charset cs, float avgBpc, float maxBpc, |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
400 |
SingleByte.Encoder enc0201, |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
401 |
DoubleByte.Encoder enc0208, |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
402 |
DoubleByte.Encoder enc0212) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
403 |
super(cs, avgBpc, maxBpc); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
404 |
this.enc0201 = enc0201; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
405 |
this.enc0208 = enc0208; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
406 |
this.enc0212 = enc0212; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
407 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
408 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
409 |
public boolean canEncode(char c) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
410 |
byte[] encodedBytes = new byte[3]; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
411 |
return encodeSingle(c, encodedBytes) != 0 || |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
412 |
encodeDouble(c) != UNMAPPABLE_ENCODING; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
413 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
414 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
415 |
private final static String G1_c = "\u00A2\u00A3\u00AC"; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
416 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
417 |
protected int encodeSingle(char inputChar, byte[] outputByte) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
418 |
if (inputChar >= 0x80 && inputChar < 0x8e) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
419 |
outputByte[0] = (byte)inputChar; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
420 |
return 1; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
421 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
422 |
if (inputChar >= 0x90 && inputChar < 0xa0) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
423 |
outputByte[0] = (byte)inputChar; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
424 |
return 1; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
425 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
426 |
int b = enc0201.encode(inputChar); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
427 |
if (b == UNMAPPABLE_ENCODING) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
428 |
int idx = G1_c.indexOf(inputChar); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
429 |
if (idx > -1) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
430 |
b = 0xe0 + idx; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
431 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
432 |
if (b == UNMAPPABLE_ENCODING) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
433 |
return 0; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
434 |
if (b >= 0 && b < 128) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
435 |
outputByte[0] = (byte)b; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
436 |
return 1; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
437 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
438 |
outputByte[0] = (byte)0x8e; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
439 |
outputByte[1] = (byte)b; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
440 |
return 2; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
441 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
442 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
443 |
protected int encodeUDC(char ch) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
444 |
if (ch >= '\ue000' && ch <= '\ue757') { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
445 |
if (ch < '\ue3ac') { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
446 |
int offset = (int)ch - 0xe000; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
447 |
int b = ((offset / 94) << 8) + (offset % 94); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
448 |
return b + 0xf5a1; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
449 |
} else { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
450 |
int offset = (int)ch - 0xe3ac; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
451 |
int b = ((offset / 94) << 8) + (offset % 94); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
452 |
return b + 0x8ff5a1; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
453 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
454 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
455 |
return UNMAPPABLE_ENCODING; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
456 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
457 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
458 |
protected int encodeDouble(char ch) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
459 |
int idx = G2_c.indexOf(ch); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
460 |
if (idx > -1) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
461 |
return (int)G2_b.charAt(idx); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
462 |
idx = G3_c.indexOf(ch); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
463 |
if (idx > -1) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
464 |
return (int)G3_b.charAt(idx) + 0x8f0000; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
465 |
int b = enc0208.encodeChar(ch); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
466 |
if (b != UNMAPPABLE_ENCODING) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
467 |
return b + 0x8080; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
468 |
b = encodeUDC(ch); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
469 |
if (b != UNMAPPABLE_ENCODING) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
470 |
return b; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
471 |
if (ibm943.canEncode(ch)) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
472 |
b = enc0212.encodeChar(ch); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
473 |
if (b != UNMAPPABLE_ENCODING) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
474 |
b += 0x8F8080; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
475 |
return b; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
476 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
477 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
478 |
return b; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
479 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
480 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
481 |
private CoderResult encodeArrayLoop(CharBuffer src, |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
482 |
ByteBuffer dst) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
483 |
{ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
484 |
char[] sa = src.array(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
485 |
int sp = src.arrayOffset() + src.position(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
486 |
int sl = src.arrayOffset() + src.limit(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
487 |
assert (sp <= sl); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
488 |
sp = (sp <= sl ? sp : sl); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
489 |
byte[] da = dst.array(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
490 |
int dp = dst.arrayOffset() + dst.position(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
491 |
int dl = dst.arrayOffset() + dst.limit(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
492 |
assert (dp <= dl); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
493 |
dp = (dp <= dl ? dp : dl); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
494 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
495 |
int outputSize = 0; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
496 |
byte[] outputByte; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
497 |
int inputSize = 0; // Size of input |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
498 |
byte[] tmpBuf = new byte[3]; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
499 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
500 |
try { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
501 |
while (sp < sl) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
502 |
outputByte = tmpBuf; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
503 |
char c = sa[sp]; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
504 |
if (Character.isSurrogate(c)) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
505 |
if (sgp.parse(c, sa, sp, sl) < 0) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
506 |
return sgp.error(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
507 |
return sgp.unmappableResult(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
508 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
509 |
outputSize = encodeSingle(c, outputByte); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
510 |
if (outputSize == 0) { // DoubleByte |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
511 |
int ncode = encodeDouble(c); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
512 |
if (ncode != UNMAPPABLE_ENCODING) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
513 |
if ((ncode & 0xFF0000) == 0) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
514 |
outputByte[0] = (byte) ((ncode & 0xff00) >> 8); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
515 |
outputByte[1] = (byte) (ncode & 0xff); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
516 |
outputSize = 2; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
517 |
} else { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
518 |
outputByte[0] = (byte) 0x8f; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
519 |
outputByte[1] = (byte) ((ncode & 0xff00) >> 8); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
520 |
outputByte[2] = (byte) (ncode & 0xff); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
521 |
outputSize = 3; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
522 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
523 |
} else { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
524 |
return CoderResult.unmappableForLength(1); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
525 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
526 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
527 |
if (dl - dp < outputSize) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
528 |
return CoderResult.OVERFLOW; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
529 |
// Put the byte in the output buffer |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
530 |
for (int i = 0; i < outputSize; i++) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
531 |
da[dp++] = outputByte[i]; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
532 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
533 |
sp++; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
534 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
535 |
return CoderResult.UNDERFLOW; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
536 |
} finally { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
537 |
src.position(sp - src.arrayOffset()); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
538 |
dst.position(dp - dst.arrayOffset()); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
539 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
540 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
541 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
542 |
private CoderResult encodeBufferLoop(CharBuffer src, |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
543 |
ByteBuffer dst) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
544 |
{ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
545 |
int outputSize = 0; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
546 |
byte[] outputByte; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
547 |
int inputSize = 0; // Size of input |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
548 |
byte[] tmpBuf = new byte[3]; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
549 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
550 |
int mark = src.position(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
551 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
552 |
try { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
553 |
while (src.hasRemaining()) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
554 |
outputByte = tmpBuf; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
555 |
char c = src.get(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
556 |
if (Character.isSurrogate(c)) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
557 |
if (sgp.parse(c, src) < 0) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
558 |
return sgp.error(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
559 |
return sgp.unmappableResult(); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
560 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
561 |
outputSize = encodeSingle(c, outputByte); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
562 |
if (outputSize == 0) { // DoubleByte |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
563 |
int ncode = encodeDouble(c); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
564 |
if (ncode != UNMAPPABLE_ENCODING) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
565 |
if ((ncode & 0xFF0000) == 0) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
566 |
outputByte[0] = (byte) ((ncode & 0xff00) >> 8); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
567 |
outputByte[1] = (byte) (ncode & 0xff); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
568 |
outputSize = 2; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
569 |
} else { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
570 |
outputByte[0] = (byte) 0x8f; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
571 |
outputByte[1] = (byte) ((ncode & 0xff00) >> 8); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
572 |
outputByte[2] = (byte) (ncode & 0xff); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
573 |
outputSize = 3; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
574 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
575 |
} else { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
576 |
return CoderResult.unmappableForLength(1); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
577 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
578 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
579 |
if (dst.remaining() < outputSize) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
580 |
return CoderResult.OVERFLOW; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
581 |
// Put the byte in the output buffer |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
582 |
for (int i = 0; i < outputSize; i++) { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
583 |
dst.put(outputByte[i]); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
584 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
585 |
mark++; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
586 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
587 |
return CoderResult.UNDERFLOW; |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
588 |
} finally { |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
589 |
src.position(mark); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
590 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
591 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
592 |
|
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
593 |
protected CoderResult encodeLoop(CharBuffer src, |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
594 |
ByteBuffer dst) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
595 |
{ |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
596 |
if (src.hasArray() && dst.hasArray()) |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
597 |
return encodeArrayLoop(src, dst); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
598 |
else |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
599 |
return encodeBufferLoop(src, dst); |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
600 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
601 |
} |
1262a93634c2
8214533: IBM-29626C is required for AIX default charset
itakiguchi
parents:
diff
changeset
|
602 |
} |