2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved.
|
2
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
5506
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
5506
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
2
|
24 |
*/
|
|
25 |
|
|
26 |
/*
|
|
27 |
*/
|
|
28 |
|
|
29 |
package sun.nio.cs.ext;
|
|
30 |
|
|
31 |
import java.nio.charset.Charset;
|
|
32 |
import java.nio.charset.CharsetDecoder;
|
|
33 |
import java.nio.charset.CharsetEncoder;
|
|
34 |
import sun.nio.cs.SingleByteEncoder;
|
|
35 |
import sun.nio.cs.SingleByteDecoder;
|
|
36 |
|
|
37 |
public class JIS_X_0201
|
|
38 |
extends Charset
|
|
39 |
{
|
|
40 |
|
|
41 |
public JIS_X_0201() {
|
|
42 |
super("JIS_X0201", ExtendedCharsets.aliasesFor("JIS_X0201"));
|
|
43 |
}
|
|
44 |
|
|
45 |
public boolean contains(Charset cs) {
|
|
46 |
return ((cs.name().equals("US-ASCII"))
|
|
47 |
|| (cs instanceof JIS_X_0201));
|
|
48 |
}
|
|
49 |
|
|
50 |
public CharsetDecoder newDecoder() {
|
|
51 |
return new Decoder(this);
|
|
52 |
}
|
|
53 |
|
|
54 |
public CharsetEncoder newEncoder() {
|
|
55 |
return new Encoder(this);
|
|
56 |
}
|
|
57 |
|
|
58 |
public static class Decoder extends SingleByteDecoder {
|
|
59 |
|
|
60 |
public Decoder(Charset cs) {
|
|
61 |
super(cs, byteToCharTable);
|
|
62 |
}
|
|
63 |
|
|
64 |
private final static String byteToCharTable =
|
|
65 |
|
|
66 |
"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD" + // 0x80 - 0x87
|
|
67 |
"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD" + // 0x88 - 0x8F
|
|
68 |
"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD" + // 0x90 - 0x97
|
|
69 |
"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD" + // 0x98 - 0x9F
|
|
70 |
"\uFFFD\uFF61\uFF62\uFF63\uFF64\uFF65\uFF66\uFF67" + // 0xA0 - 0xA7
|
|
71 |
"\uFF68\uFF69\uFF6A\uFF6B\uFF6C\uFF6D\uFF6E\uFF6F" + // 0xA8 - 0xAF
|
|
72 |
"\uFF70\uFF71\uFF72\uFF73\uFF74\uFF75\uFF76\uFF77" + // 0xB0 - 0xB7
|
|
73 |
"\uFF78\uFF79\uFF7A\uFF7B\uFF7C\uFF7D\uFF7E\uFF7F" + // 0xB8 - 0xBF
|
|
74 |
"\uFF80\uFF81\uFF82\uFF83\uFF84\uFF85\uFF86\uFF87" + // 0xC0 - 0xC7
|
|
75 |
"\uFF88\uFF89\uFF8A\uFF8B\uFF8C\uFF8D\uFF8E\uFF8F" + // 0xC8 - 0xCF
|
|
76 |
"\uFF90\uFF91\uFF92\uFF93\uFF94\uFF95\uFF96\uFF97" + // 0xD0 - 0xD7
|
|
77 |
"\uFF98\uFF99\uFF9A\uFF9B\uFF9C\uFF9D\uFF9E\uFF9F" + // 0xD8 - 0xDF
|
|
78 |
"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD" + // 0xE0 - 0xE7
|
|
79 |
"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD" + // 0xE8 - 0xEF
|
|
80 |
"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD" + // 0xF0 - 0xF7
|
|
81 |
"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD" + // 0xF8 - 0xFF
|
|
82 |
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
|
83 |
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0F
|
|
84 |
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
|
85 |
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1F
|
|
86 |
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
|
87 |
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2F
|
|
88 |
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
|
89 |
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3F
|
|
90 |
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
|
91 |
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4F
|
|
92 |
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
|
93 |
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5F
|
|
94 |
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
|
95 |
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6F
|
|
96 |
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
|
97 |
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F"; // 0x78 - 0x7F
|
|
98 |
}
|
|
99 |
|
|
100 |
public static class Encoder extends SingleByteEncoder {
|
|
101 |
|
|
102 |
public Encoder(Charset cs) {
|
|
103 |
super(cs, index1, index2, 0xFF00, 0x00FF, 8);
|
|
104 |
}
|
|
105 |
|
|
106 |
private final static String index2 =
|
|
107 |
|
|
108 |
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" +
|
|
109 |
"\b\t\n\u000B\f\r\u000E\u000F" +
|
|
110 |
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" +
|
|
111 |
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" +
|
|
112 |
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" +
|
|
113 |
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" +
|
|
114 |
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" +
|
|
115 |
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" +
|
|
116 |
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" +
|
|
117 |
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" +
|
|
118 |
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" +
|
|
119 |
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" +
|
|
120 |
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" +
|
|
121 |
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" +
|
|
122 |
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" +
|
|
123 |
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" +
|
|
124 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
125 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
126 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
127 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
128 |
"\u0000\u0000\u0000\u0000\u0000\\\u0000\u0000" +
|
|
129 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
130 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
131 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
132 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
133 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
134 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
135 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
136 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
137 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
138 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
139 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
140 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
141 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
142 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
143 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
144 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
145 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
146 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
147 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
148 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
149 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
150 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
151 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
152 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
153 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
154 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
155 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
156 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
157 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
158 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
159 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
160 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u007E\u0000" +
|
|
161 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
162 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
163 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
164 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
165 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
166 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
167 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
168 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
169 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
170 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
171 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
172 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
173 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
174 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
175 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
176 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
177 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
178 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
179 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
180 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
181 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
182 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
183 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
184 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
185 |
"\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A8" +
|
|
186 |
"\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF\u00B0" +
|
|
187 |
"\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7\u00B8" +
|
|
188 |
"\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF\u00C0" +
|
|
189 |
"\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8" +
|
|
190 |
"\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D0" +
|
|
191 |
"\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8" +
|
|
192 |
"\u00D9\u00DA\u00DB\u00DC\u00DD\u00DE\u00DF\u0000" +
|
|
193 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
194 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
195 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
196 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
197 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
198 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
199 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
200 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
201 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
202 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
203 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
|
|
204 |
"\u0000\u0000\u0000\u0000\u0000\u0000\u0000";
|
|
205 |
|
|
206 |
private final static short index1[] = {
|
|
207 |
0, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
|
|
208 |
166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
|
|
209 |
360, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
|
|
210 |
166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
|
|
211 |
166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
|
|
212 |
166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
|
|
213 |
166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
|
|
214 |
166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
|
|
215 |
166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
|
|
216 |
166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
|
|
217 |
166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
|
|
218 |
166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
|
|
219 |
166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
|
|
220 |
166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
|
|
221 |
166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
|
|
222 |
166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, 519,
|
|
223 |
};
|
|
224 |
}
|
|
225 |
|
|
226 |
}
|