2362N/A * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. 395N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 395N/A * This code is free software; you can redistribute it and/or modify it 395N/A * under the terms of the GNU General Public License version 2 only, as 395N/A * published by the Free Software Foundation. 395N/A * This code is distributed in the hope that it will be useful, but WITHOUT 395N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 395N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 395N/A * version 2 for more details (a copy is included in the LICENSE file that 395N/A * accompanied this code). 395N/A * You should have received a copy of the GNU General Public License version 395N/A * 2 along with this work; if not, write to the Free Software Foundation, 395N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 395N/A * @bug 4831163 5053096 5056440 395N/A * @summary NIO charset basic verification of JISAutodetect decoder 395N/A * @author Martin Buchholz 395N/A (
byte)
0xcf, (
byte)
0xb2});
395N/A (
byte)
0xa4, (
byte)
0xe9});
395N/A //---------------------------------------------------------------- 395N/A // Test special public methods of CharsetDecoder while we're here 395N/A //---------------------------------------------------------------- 395N/A //---------------------------------------------------------------- 395N/A // Used to throw BufferOverflowException 395N/A //---------------------------------------------------------------- 395N/A //---------------------------------------------------------------- 395N/A // InputStreamReader(...JISAutoDetect) used to infloop 395N/A //---------------------------------------------------------------- 395N/A // used to return "ABCD" on second and subsequent reads 395N/A //---------------------------------------------------------------- 395N/A // Check all Japanese chars for sanity 395N/A //---------------------------------------------------------------- 395N/A for (
char c =
'\u0000'; c <
'\uffff'; c++) {
395N/A if (c ==
'\u001b' ||
// ESC 395N/A c ==
'\u2014')
// Em-Dash? 395N/A //---------------------------------------------------------------- 395N/A // JISAutoDetect can handle all chars that EUC-JP can, 395N/A // unless there is an ambiguity with SJIS. 395N/A //---------------------------------------------------------------- 395N/A fail(
"Autodetection agrees with neither EUC nor SJIS");
395N/A continue;
// Optimization 395N/A //---------------------------------------------------------------- 395N/A // JISAutoDetect can handle all chars that ISO-2022-JP can. 395N/A //---------------------------------------------------------------- 395N/A "ISO2022 autodetection");
395N/A //---------------------------------------------------------------- 395N/A // JISAutoDetect can handle almost all chars that SJIS can. 395N/A //---------------------------------------------------------------- 395N/A "misdetected as SJIS after being EUC-encoded.%n",
cntBAD);
395N/A //---------------------------------------------------------------- 395N/A // tests for specific byte sequences 395N/A //---------------------------------------------------------------- 395N/A test(
"ISO-2022-JP",
new byte[] {
'A',
'B',
'C'});
395N/A test(
"EUC-JP",
new byte[] {
'A',
'B',
'C'});
395N/A new byte[] {
'C',
'o',
'p',
'y',
'r',
'i',
'g',
'h',
't',
395N/A ' ', (
byte)
0xa9,
' ',
'1',
'9',
'9',
'8' });
395N/A new byte[] { (
byte)
0xbb, (
byte)
0xdd, (
byte)
0xcf, (
byte)
0xb2,
395N/A (
byte)
0xb8, (
byte)
0xdb, (
byte)
0xbc, (
byte)
0xbd,
395N/A (
byte)
0xc3, (
byte)
0xd1, (
byte)
0xbd, (
byte)
0xde,
395N/A (
byte)
0x82, (
byte)
0xc5, (
byte)
0x82, (
byte)
0xb7 });
395N/A new byte[] { (
byte)
0xa4, (
byte)
0xd2, (
byte)
0xa4, (
byte)
0xe9,
395N/A (
byte)
0xa4, (
byte)
0xac, (
byte)
0xa4, (
byte)
0xca });
395N/A new byte[] { (
byte)
0xbb, (
byte)
0xdd, (
byte)
0xcf, (
byte)
0xb2,
395N/A (
byte)
0xb8, (
byte)
0xdb, (
byte)
0xbc, (
byte)
0xbd,
395N/A (
byte)
0xc3, (
byte)
0xd1, (
byte)
0xbd, (
byte)
0xde});
395N/A new byte[] { (
byte)
0xbb, (
byte)
0xdd, (
byte)
0xcf, (
byte)
0xb2,
395N/A (
byte)
0xb8, (
byte)
0xdb, (
byte)
0xbc, (
byte)
0xbd,
395N/A (
byte)
0xc3, (
byte)
0xd1, (
byte)
0xbd });
395N/A new byte[] { (
byte)
0x8f, (
byte)
0xa1, (
byte)
0xaa });
395N/A new byte[] { (
byte)
0x8f, (
byte)
0xc5, (
byte)
0xe0, (
byte)
0x20});
395N/A new byte[] { (
byte)
0xbb, (
byte)
0xdd, (
byte)
0xcf, (
byte)
0xb2,
395N/A (
byte)
0xb8, (
byte)
0xdb, (
byte)
0xbc, (
byte)
0xbd,
395N/A (
byte)
0xc3, (
byte)
0xd1, (
byte)
0xbd, (
byte)
0xde,
395N/A (
byte)
0xa4, (
byte)
0xc7, (
byte)
0xa4, (
byte)
0xb9 });
395N/A new byte[] {
0x1b,
'$',
'B',
'#',
'4',
'$',
'5',
0x1b,
'(',
'B' });
395N/A //---------------------------------------------------------------- 395N/A // Check handling of ambiguous end-of-input in middle of first char 395N/A //----------------------------------------------------------------