157 (byte)0x85, (byte)0x87, // 2266 ->
158 (byte)0x85, (byte)0xe0, // 32a4 ->
159 (byte)0x85, (byte)0xf0 };// 7165 fffd
160 String s = new String(bs, "Cp943");
161 // see DoubleByte for how the unmappables are handled
162 if (!"\ufffd\uff6d\ufffd\uff6e\ufffd\uff6f\ufffd\uff70\ufffd\u2266\u32a4\u7165\ufffd"
163 .equals(s))
164 throw new Exception("Cp943 failed");
165 }
166
167
168 private static void bug6577466 () throws Exception {
169 for (int c = Character.MIN_VALUE; c <= Character.MAX_VALUE; c++){
170 if (!Character.isDefined((char)c)) continue;
171 String s = String.valueOf((char)c);
172 byte[] bb = null;
173 bb = s.getBytes("x-IBM970");
174 }
175 }
176
177 private static void bug8202329() throws Exception {
178 String original = "\\\u007E\u00A5\u203E"; // [backslash][tilde][yen][overscore]
179 byte[] expectedBytes; // bytes after conversion
180 String expectedStringfromBytes; // String constructed from bytes
181
182 Charset charset; // charset used for conversion
183
184 ByteBuffer bb; // Buffer that holds encoded bytes
185 byte[] ba; // byte array that holds encoded bytes
186
187 CharBuffer cb; // Buffer that holds decoded chars
188
189
190 // Test IBM943, where \ and ~ are encoded to unmappable i.e., 0x3f
191 // and [yen] and [overscore] are encoded to 0x5c and 0x7e
192 charset = Charset.forName("IBM943");
193 expectedBytes = new byte[] {0x3f, 0x3f, 0x5c, 0x7e};
194 expectedStringfromBytes = "??\u00A5\u203E";
195 bb = charset.encode(original);
196 ba = new byte[bb.remaining()];
215 if(!Arrays.equals(ba, expectedBytes)) {
216 throw new Exception("IBM943C failed to encode");
217 }
218 cb = charset.decode(ByteBuffer.wrap(expectedBytes));
219 if(!cb.toString().equals(expectedStringfromBytes)) {
220 throw new Exception("IBM943C failed to decode");
221 }
222 }
223
224 public static void main (String[] args) throws Exception {
225 bug6577466();
226 // need to be tested before any other IBM949C test case
227 bug6639450();
228 bug6371437();
229 bug6371422();
230 bug6371416();
231 bug6371619();
232 bug6371431();
233 bug6569191();
234 bug8202329();
235 }
236 }
|
157 (byte)0x85, (byte)0x87, // 2266 ->
158 (byte)0x85, (byte)0xe0, // 32a4 ->
159 (byte)0x85, (byte)0xf0 };// 7165 fffd
160 String s = new String(bs, "Cp943");
161 // see DoubleByte for how the unmappables are handled
162 if (!"\ufffd\uff6d\ufffd\uff6e\ufffd\uff6f\ufffd\uff70\ufffd\u2266\u32a4\u7165\ufffd"
163 .equals(s))
164 throw new Exception("Cp943 failed");
165 }
166
167
168 private static void bug6577466 () throws Exception {
169 for (int c = Character.MIN_VALUE; c <= Character.MAX_VALUE; c++){
170 if (!Character.isDefined((char)c)) continue;
171 String s = String.valueOf((char)c);
172 byte[] bb = null;
173 bb = s.getBytes("x-IBM970");
174 }
175 }
176
177 private static void bug8213618 () throws Exception {
178 String cs = "x-IBM970";
179 byte[] ba = new byte[]{(byte)0xA2,(byte)0xC1};
180 String s = "\u25C9";
181 if (!(new String(ba, cs)).equals(s))
182 throw new Exception("Cp970 failed");
183 if (!Arrays.equals(ba, s.getBytes(cs)))
184 throw new Exception("Cp970 failed");
185 ba = new byte[]{0x3f,0x3f,0x3f};
186 if (!Arrays.equals(ba, "\u6950\u84f1\ucf7f".getBytes(cs)))
187 throw new Exception("Cp970 failed");
188 }
189
190 private static void bug8202329() throws Exception {
191 String original = "\\\u007E\u00A5\u203E"; // [backslash][tilde][yen][overscore]
192 byte[] expectedBytes; // bytes after conversion
193 String expectedStringfromBytes; // String constructed from bytes
194
195 Charset charset; // charset used for conversion
196
197 ByteBuffer bb; // Buffer that holds encoded bytes
198 byte[] ba; // byte array that holds encoded bytes
199
200 CharBuffer cb; // Buffer that holds decoded chars
201
202
203 // Test IBM943, where \ and ~ are encoded to unmappable i.e., 0x3f
204 // and [yen] and [overscore] are encoded to 0x5c and 0x7e
205 charset = Charset.forName("IBM943");
206 expectedBytes = new byte[] {0x3f, 0x3f, 0x5c, 0x7e};
207 expectedStringfromBytes = "??\u00A5\u203E";
208 bb = charset.encode(original);
209 ba = new byte[bb.remaining()];
228 if(!Arrays.equals(ba, expectedBytes)) {
229 throw new Exception("IBM943C failed to encode");
230 }
231 cb = charset.decode(ByteBuffer.wrap(expectedBytes));
232 if(!cb.toString().equals(expectedStringfromBytes)) {
233 throw new Exception("IBM943C failed to decode");
234 }
235 }
236
237 public static void main (String[] args) throws Exception {
238 bug6577466();
239 // need to be tested before any other IBM949C test case
240 bug6639450();
241 bug6371437();
242 bug6371422();
243 bug6371416();
244 bug6371619();
245 bug6371431();
246 bug6569191();
247 bug8202329();
248 bug8213618();
249 }
250 }
|