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"; // "b"; \\ [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 ¥ andoverscore 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()];
197 bb.get(ba, 0, ba.length);
198 if(!Arrays.equals(ba, expectedBytes)) {
199 throw new Exception("IBM943 failed to encode");
200 }
201 cb = charset.decode(ByteBuffer.wrap(expectedBytes));
202 if(!cb.toString().equals(expectedStringfromBytes)) {
203 throw new Exception("IBM943 failed to decode");
204 }
205
206
207 // Test IBM943C, where \ and ~ are encoded to 0x5c and 0x7e
208 // and ¥ an overscore are encoded to 0x5c and 0x7e
209 charset = Charset.forName("IBM943C");
210 expectedBytes = new byte[] {0x5c, 0x7e, 0x5c, 0x7e};
211 expectedStringfromBytes = "\\~\\~";
212 bb = charset.encode(original);
213 ba = new byte[bb.remaining()];
214 bb.get(ba, 0, ba.length);
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();
|
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()];
197 bb.get(ba, 0, ba.length);
198 if(!Arrays.equals(ba, expectedBytes)) {
199 throw new Exception("IBM943 failed to encode");
200 }
201 cb = charset.decode(ByteBuffer.wrap(expectedBytes));
202 if(!cb.toString().equals(expectedStringfromBytes)) {
203 throw new Exception("IBM943 failed to decode");
204 }
205
206
207 // Test IBM943C, where \ and ~ are encoded to 0x5c and 0x7e
208 // and [yen] an [overscore] are encoded to 0x5c and 0x7e
209 charset = Charset.forName("IBM943C");
210 expectedBytes = new byte[] {0x5c, 0x7e, 0x5c, 0x7e};
211 expectedStringfromBytes = "\\~\\~";
212 bb = charset.encode(original);
213 ba = new byte[bb.remaining()];
214 bb.get(ba, 0, ba.length);
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();
|