From 9ff890cea1b2daaa6ff7b58c49a6deb7c99827b5 Mon Sep 17 00:00:00 2001 From: duke Date: Sun, 5 Oct 2025 17:39:34 +0000 Subject: [PATCH] Backport 09174e0c994dfb19fd09f551720c13c6479812d4 --- .../Charset/AvailableCharsetNames.java | 29 +- .../Charset/CharsetContainmentTest.java | 181 +- .../java/nio/charset/Charset/Contains.java | 306 +- .../nio/charset/Charset/EmptyCharsetName.java | 84 - test/jdk/java/nio/charset/Charset/EncDec.java | 39 +- .../charset/Charset/IllegalCharsetName.java | 106 +- .../nio/charset/Charset/NullCharsetName.java | 30 +- .../charset/Charset/RegisteredCharsets.java | 2568 +++++++++-------- 8 files changed, 1696 insertions(+), 1647 deletions(-) delete mode 100644 test/jdk/java/nio/charset/Charset/EmptyCharsetName.java diff --git a/test/jdk/java/nio/charset/Charset/AvailableCharsetNames.java b/test/jdk/java/nio/charset/Charset/AvailableCharsetNames.java index 078700f2fae..0f20e957605 100644 --- a/test/jdk/java/nio/charset/Charset/AvailableCharsetNames.java +++ b/test/jdk/java/nio/charset/Charset/AvailableCharsetNames.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,27 +25,26 @@ * @bug 4422044 * @summary Ensure that keys in available-charset map * are identical to canonical names + * @run junit AvailableCharsetNames */ -import java.io.*; -import java.nio.*; -import java.nio.charset.*; -import java.util.*; +import java.nio.charset.Charset; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class AvailableCharsetNames { - public static void main(String[] args) throws Exception { - Iterator charsetIterator = Charset.availableCharsets().keySet().iterator(); - while (charsetIterator.hasNext()) { - String charsetName = (String) charsetIterator.next(); + /** + * Test that the keys in Charset.availableCharsets() + * are equal to the associated Charset.name() value. + */ + @Test + public void canonicalNamesTest() { + for (String charsetName : Charset.availableCharsets().keySet()) { Charset charset = Charset.forName(charsetName); - if (!charset.name().equals(charsetName)) { - throw new Exception("Error: Charset name mismatch - expected " - + charsetName + ", got " + charset.name()); - } + assertEquals(charset.name(), charsetName, "Charset name mismatch"); } - } - } diff --git a/test/jdk/java/nio/charset/Charset/CharsetContainmentTest.java b/test/jdk/java/nio/charset/Charset/CharsetContainmentTest.java index 7e763f7750c..4bc05388219 100644 --- a/test/jdk/java/nio/charset/Charset/CharsetContainmentTest.java +++ b/test/jdk/java/nio/charset/Charset/CharsetContainmentTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,93 +25,116 @@ * @bug 4626545 4696726 * @summary Checks the inter containment relationships between NIO charsets * @modules jdk.charsets + * @run junit CharsetContainmentTest */ -import java.nio.charset.*; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; -public class CharsetContainmentTest { - static String[] encodings = - { "US-ASCII", "UTF-16", "UTF-16BE", "UTF-16LE", "UTF-8", - "windows-1252", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", - "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", - "ISO-8859-8", "ISO-8859-9", "ISO-8859-13", "ISO-8859-15", "ISO-8859-16", - "ISO-2022-JP", "ISO-2022-KR", +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; - // Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder - // support is added (4673614) - // "x-ISO-2022-CN-CNS", "x-ISO-2022-CN-GB", +import static org.junit.jupiter.api.Assertions.assertTrue; - "x-ISCII91", "GBK", "GB18030", "Big5", - "x-EUC-TW", "GB2312", "EUC-KR", "x-Johab", "Big5-HKSCS", - "x-MS950-HKSCS", "windows-1251", "windows-1253", "windows-1254", - "windows-1255", "windows-1256", "windows-1257", "windows-1258", - "x-mswin-936", "x-windows-949", "x-windows-950", "windows-31j", - "Shift_JIS", "EUC-JP", "KOI8-R", "TIS-620" - }; +public class CharsetContainmentTest { - static String[][] contains = { - { "US-ASCII"}, - encodings, - encodings, - encodings, - encodings, - {"US-ASCII", "windows-1252"}, - {"US-ASCII", "ISO-8859-1"}, - {"US-ASCII", "ISO-8859-2"}, - {"US-ASCII", "ISO-8859-3"}, - {"US-ASCII", "ISO-8859-4"}, - {"US-ASCII", "ISO-8859-5"}, - {"US-ASCII", "ISO-8859-6"}, - {"US-ASCII", "ISO-8859-7"}, - {"US-ASCII", "ISO-8859-8"}, - {"US-ASCII", "ISO-8859-9"}, - {"US-ASCII", "ISO-8859-13"}, - {"US-ASCII", "ISO-8859-15"}, - {"US-ASCII", "ISO-8859-16"}, - {"ISO-2022-JP"}, - {"ISO-2022-KR"}, - // Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder - // support is added (4673614) - //{"x-ISO-2022-CN-CNS"}, - //{"x-ISO-2022-CN-GB"}, - {"US-ASCII", "x-ISCII91"}, - {"US-ASCII", "GBK"}, - encodings, - {"US-ASCII", "Big5"}, - {"US-ASCII", "x-EUC-TW"}, - {"US-ASCII", "GB2312"}, - {"US-ASCII", "EUC-KR"}, - {"US-ASCII", "x-Johab"}, - {"US-ASCII", "Big5-HKSCS", "Big5"}, - {"US-ASCII", "x-MS950-HKSCS", "x-windows-950"}, - {"US-ASCII", "windows-1251"}, - {"US-ASCII", "windows-1253"}, - {"US-ASCII", "windows-1254"}, - {"US-ASCII", "windows-1255"}, - {"US-ASCII", "windows-1256"}, - {"US-ASCII", "windows-1257"}, - {"US-ASCII", "windows-1258"}, - {"US-ASCII", "x-mswin-936"}, - {"US-ASCII", "x-windows-949"}, - {"US-ASCII", "x-windows-950"}, - {"US-ASCII", "windows-31j" }, - {"US-ASCII", "Shift_JIS"}, - {"US-ASCII", "EUC-JP"}, - {"US-ASCII", "KOI8-R"}, - {"US-ASCII", "TIS-620"}}; + /** + * Test that the charsets in 'encodings' contain the charsets + * inside 'contains'. Each value in 'encodings' is mapped to a String + * array in 'contains'. For example, the value, "TIS-620" in 'encodings' + * should contain "US-ASCII", "TIS-620". + */ + @ParameterizedTest + @MethodSource("charsets") + public void interContainmentTest(String containerName, String containedName) { + Charset container = Charset.forName(containerName); + Charset contained = Charset.forName(containedName); + assertTrue(container.contains(contained), + String.format("Charset: %s does not contain: %s", containerName, containedName)); + } + private static Stream charsets() { + String[] encodings = { + "US-ASCII", "UTF-16", "UTF-16BE", "UTF-16LE", "UTF-8", + "windows-1252", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", + "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", + "ISO-8859-8", "ISO-8859-9", "ISO-8859-13", "ISO-8859-15", "ISO-8859-16", + "ISO-2022-JP", "ISO-2022-KR", + // Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder + // support is added (4673614) + // "x-ISO-2022-CN-CNS", "x-ISO-2022-CN-GB", + "x-ISCII91", "GBK", "GB18030", "Big5", + "x-EUC-TW", "GB2312", "EUC-KR", "x-Johab", "Big5-HKSCS", + "x-MS950-HKSCS", "windows-1251", "windows-1253", "windows-1254", + "windows-1255", "windows-1256", "windows-1257", "windows-1258", + "x-mswin-936", "x-windows-949", "x-windows-950", "windows-31j", + "Shift_JIS", "EUC-JP", "KOI8-R", "TIS-620" + }; - public static void main(String[] args) throws Exception { + String[][] contains = { + {"US-ASCII"}, + encodings, + encodings, + encodings, + encodings, + {"US-ASCII", "windows-1252"}, + {"US-ASCII", "ISO-8859-1"}, + {"US-ASCII", "ISO-8859-2"}, + {"US-ASCII", "ISO-8859-3"}, + {"US-ASCII", "ISO-8859-4"}, + {"US-ASCII", "ISO-8859-5"}, + {"US-ASCII", "ISO-8859-6"}, + {"US-ASCII", "ISO-8859-7"}, + {"US-ASCII", "ISO-8859-8"}, + {"US-ASCII", "ISO-8859-9"}, + {"US-ASCII", "ISO-8859-13"}, + {"US-ASCII", "ISO-8859-15"}, + {"US-ASCII", "ISO-8859-16"}, + {"ISO-2022-JP"}, + {"ISO-2022-KR"}, + // Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder + // support is added (4673614) + //{"x-ISO-2022-CN-CNS"}, + //{"x-ISO-2022-CN-GB"}, + {"US-ASCII", "x-ISCII91"}, + {"US-ASCII", "GBK"}, + encodings, + {"US-ASCII", "Big5"}, + {"US-ASCII", "x-EUC-TW"}, + {"US-ASCII", "GB2312"}, + {"US-ASCII", "EUC-KR"}, + {"US-ASCII", "x-Johab"}, + {"US-ASCII", "Big5-HKSCS", "Big5"}, + {"US-ASCII", "x-MS950-HKSCS", "x-windows-950"}, + {"US-ASCII", "windows-1251"}, + {"US-ASCII", "windows-1253"}, + {"US-ASCII", "windows-1254"}, + {"US-ASCII", "windows-1255"}, + {"US-ASCII", "windows-1256"}, + {"US-ASCII", "windows-1257"}, + {"US-ASCII", "windows-1258"}, + {"US-ASCII", "x-mswin-936"}, + {"US-ASCII", "x-windows-949"}, + {"US-ASCII", "x-windows-950"}, + {"US-ASCII", "windows-31j"}, + {"US-ASCII", "Shift_JIS"}, + {"US-ASCII", "EUC-JP"}, + {"US-ASCII", "KOI8-R"}, + {"US-ASCII", "TIS-620"}}; + + // Length of encodings and contains should always be equal + if (encodings.length != contains.length) { + throw new RuntimeException("Testing data is not set up correctly"); + } + List charsetList = new ArrayList(); for (int i = 0; i < encodings.length; i++) { - Charset c = Charset.forName(encodings[i]); - for (int j = 0 ; j < contains[i].length; j++) { - if (c.contains(Charset.forName(contains[i][j]))) - continue; - else { - throw new Exception ("Error: charset " + encodings[i] + - "doesn't contain " + contains[i][j]); - } - } + for (int j = 0 ; j < contains[i].length; j++) { + charsetList.add(Arguments.of(encodings[i], contains[i][j])); + } } + return charsetList.stream(); } } diff --git a/test/jdk/java/nio/charset/Charset/Contains.java b/test/jdk/java/nio/charset/Charset/Contains.java index 0e5cf637231..502c22873c3 100644 --- a/test/jdk/java/nio/charset/Charset/Contains.java +++ b/test/jdk/java/nio/charset/Charset/Contains.java @@ -25,166 +25,186 @@ * @summary Unit test for charset containment * @bug 6798572 8167252 * @modules jdk.charsets + * @run junit Contains */ -import java.nio.charset.*; +import java.nio.charset.Charset; +import java.util.Arrays; +import java.util.stream.Stream; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -public class Contains { - - static void ck(Charset cs1, Charset cs2, boolean cont) throws Exception { - if ((cs1.contains(cs2)) != cont) - throw new Exception("Wrong answer: " - + cs1.name() + " contains " + cs2.name()); - System.err.println(cs1.name() - + (cont ? " contains " : " does not contain ") - + cs2.name()); - } - - public static void main(String[] args) throws Exception { +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; - Charset us_ascii = Charset.forName("US-ASCII"); - Charset iso_8859_1 = Charset.forName("ISO-8859-1"); - Charset iso_8859_15 = Charset.forName("ISO-8859-15"); - Charset utf_8 = Charset.forName("UTF-8"); - Charset utf_16be = Charset.forName("UTF-16BE"); - Charset cp1252 = Charset.forName("CP1252"); +public class Contains { - ck(us_ascii, us_ascii, true); - ck(us_ascii, iso_8859_1, false); - ck(us_ascii, iso_8859_15, false); - ck(us_ascii, utf_8, false); - ck(us_ascii, utf_16be, false); - ck(us_ascii, cp1252, false); - - ck(iso_8859_1, us_ascii, true); - ck(iso_8859_1, iso_8859_1, true); - ck(iso_8859_1, iso_8859_15, false); - ck(iso_8859_1, utf_8, false); - ck(iso_8859_1, utf_16be, false); - ck(iso_8859_1, cp1252, false); - - ck(iso_8859_15, us_ascii, true); - ck(iso_8859_15, iso_8859_1, false); - ck(iso_8859_15, iso_8859_15, true); - ck(iso_8859_15, utf_8, false); - ck(iso_8859_15, utf_16be, false); - ck(iso_8859_15, cp1252, false); - - ck(utf_8, us_ascii, true); - ck(utf_8, iso_8859_1, true); - ck(utf_8, iso_8859_15, true); - ck(utf_8, utf_8, true); - ck(utf_8, utf_16be, true); - ck(utf_8, cp1252, true); - - ck(utf_16be, us_ascii, true); - ck(utf_16be, iso_8859_1, true); - ck(utf_16be, iso_8859_15, true); - ck(utf_16be, utf_8, true); - ck(utf_16be, utf_16be, true); - ck(utf_16be, cp1252, true); - - ck(cp1252, us_ascii, true); - ck(cp1252, iso_8859_1, false); - ck(cp1252, iso_8859_15, false); - ck(cp1252, utf_8, false); - ck(cp1252, utf_16be, false); - ck(cp1252, cp1252, true); - - checkUTF(); - - containsSelfTest(); + /** + * Tests the containment of some charsets against themselves. + * This test takes both true and false for 'cont'. + */ + @ParameterizedTest + @MethodSource("charsets") + public void charsetsTest(Charset containerCs, Charset cs, boolean cont){ + shouldContain(containerCs, cs, cont); } - static void checkUTF() throws Exception { - for (String utfName : utfNames) - for (String csName : charsetNames) - ck(Charset.forName(utfName), - Charset.forName(csName), - true); + /** + * Tests UTF charsets with other charsets. In this case, each UTF charset + * should contain every single charset they are tested against. 'cont' is + * always true. + */ + @ParameterizedTest + @MethodSource("utfCharsets") + public void UTFCharsetsTest(Charset containerCs, Charset cs, boolean cont){ + shouldContain(containerCs, cs, cont); } /** * Tests the assertion in the contains() method: "Every charset contains itself." */ - static void containsSelfTest() { - boolean failed = false; - + @Test + public void containsSelfTest() { for (var entry : Charset.availableCharsets().entrySet()) { Charset charset = entry.getValue(); boolean contains = charset.contains(charset); - - System.out.println("Charset(" + charset.name() + ").contains(Charset(" + charset.name() - + ")) returns " + contains); - if (!contains) { - failed = true; - } - } - if (failed) { - throw new RuntimeException("Charset.contains(itself) returns false for some charsets"); + assertTrue(contains, String.format("Charset(%s).contains(Charset(%s)) returns %s", + charset.name(), charset.name(), contains)); } } - static String[] utfNames = {"utf-16", - "utf-8", - "utf-16le", - "utf-16be", - "x-utf-16le-bom"}; - - static String[] charsetNames = { - "US-ASCII", - "UTF-8", - "UTF-16", - "UTF-16BE", - "UTF-16LE", - "x-UTF-16LE-BOM", - "GBK", - "GB18030", - "ISO-8859-1", - "ISO-8859-15", - "ISO-8859-2", - "ISO-8859-3", - "ISO-8859-4", - "ISO-8859-5", - "ISO-8859-6", - "ISO-8859-7", - "ISO-8859-8", - "ISO-8859-9", - "ISO-8859-13", - "JIS_X0201", - "x-JIS0208", - "JIS_X0212-1990", - "GB2312", - "EUC-KR", - "x-EUC-TW", - "EUC-JP", - "x-euc-jp-linux", - "KOI8-R", - "TIS-620", - "x-ISCII91", - "windows-1251", - "windows-1252", - "windows-1253", - "windows-1254", - "windows-1255", - "windows-1256", - "windows-1257", - "windows-1258", - "windows-932", - "x-mswin-936", - "x-windows-949", - "x-windows-950", - "windows-31j", - "Big5", - "Big5-HKSCS", - "x-MS950-HKSCS", - "ISO-2022-JP", - "ISO-2022-KR", - "x-ISO-2022-CN-CNS", - "x-ISO-2022-CN-GB", - "Big5-HKSCS", - "x-Johab", - "Shift_JIS" - }; + /** + * Helper method that checks if a charset should contain another charset. + */ + static void shouldContain(Charset containerCs, Charset cs, boolean cont){ + assertEquals((containerCs.contains(cs)), cont, String.format("%s %s %s", + containerCs.name(), (cont ? " contains " : " does not contain "), cs.name())); + } + + private static Stream utfCharsets() { + String[] utfNames = { + "utf-16", + "utf-8", + "utf-16le", + "utf-16be", + "x-utf-16le-bom" + }; + + String[] charsetNames = { + "US-ASCII", + "UTF-8", + "UTF-16", + "UTF-16BE", + "UTF-16LE", + "x-UTF-16LE-BOM", + "GBK", + "GB18030", + "ISO-8859-1", + "ISO-8859-15", + "ISO-8859-2", + "ISO-8859-3", + "ISO-8859-4", + "ISO-8859-5", + "ISO-8859-6", + "ISO-8859-7", + "ISO-8859-8", + "ISO-8859-9", + "ISO-8859-13", + "JIS_X0201", + "x-JIS0208", + "JIS_X0212-1990", + "GB2312", + "EUC-KR", + "x-EUC-TW", + "EUC-JP", + "x-euc-jp-linux", + "KOI8-R", + "TIS-620", + "x-ISCII91", + "windows-1251", + "windows-1252", + "windows-1253", + "windows-1254", + "windows-1255", + "windows-1256", + "windows-1257", + "windows-1258", + "windows-932", + "x-mswin-936", + "x-windows-949", + "x-windows-950", + "windows-31j", + "Big5", + "Big5-HKSCS", + "x-MS950-HKSCS", + "ISO-2022-JP", + "ISO-2022-KR", + "x-ISO-2022-CN-CNS", + "x-ISO-2022-CN-GB", + "Big5-HKSCS", + "x-Johab", + "Shift_JIS" + }; + + // All charsets in utfNames should contain + // all charsets in charsetNames + return Arrays.stream(utfNames).flatMap(cs1 -> Arrays.stream(charsetNames) + .map(cs2 -> Arguments.of(Charset.forName(cs1), Charset.forName(cs2), true))); + } + + private static Stream charsets() { + Charset us_ascii = Charset.forName("US-ASCII"); + Charset iso_8859_1 = Charset.forName("ISO-8859-1"); + Charset iso_8859_15 = Charset.forName("ISO-8859-15"); + Charset utf_8 = Charset.forName("UTF-8"); + Charset utf_16be = Charset.forName("UTF-16BE"); + Charset cp1252 = Charset.forName("CP1252"); + + return Stream.of( + Arguments.of(us_ascii, us_ascii, true), + Arguments.of(us_ascii, iso_8859_1, false), + Arguments.of(us_ascii, iso_8859_15, false), + Arguments.of(us_ascii, utf_8, false), + Arguments.of(us_ascii, utf_16be, false), + Arguments.of(us_ascii, cp1252, false), + + Arguments.of(iso_8859_1, us_ascii, true), + Arguments.of(iso_8859_1, iso_8859_1, true), + Arguments.of(iso_8859_1, iso_8859_15, false), + Arguments.of(iso_8859_1, utf_8, false), + Arguments.of(iso_8859_1, utf_16be, false), + Arguments.of(iso_8859_1, cp1252, false), + + Arguments.of(iso_8859_15, us_ascii, true), + Arguments.of(iso_8859_15, iso_8859_1, false), + Arguments.of(iso_8859_15, iso_8859_15, true), + Arguments.of(iso_8859_15, utf_8, false), + Arguments.of(iso_8859_15, utf_16be, false), + Arguments.of(iso_8859_15, cp1252, false), + + Arguments.of(utf_8, us_ascii, true), + Arguments.of(utf_8, iso_8859_1, true), + Arguments.of(utf_8, iso_8859_15, true), + Arguments.of(utf_8, utf_8, true), + Arguments.of(utf_8, utf_16be, true), + Arguments.of(utf_8, cp1252, true), + + Arguments.of(utf_16be, us_ascii, true), + Arguments.of(utf_16be, iso_8859_1, true), + Arguments.of(utf_16be, iso_8859_15, true), + Arguments.of(utf_16be, utf_8, true), + Arguments.of(utf_16be, utf_16be, true), + Arguments.of(utf_16be, cp1252, true), + + Arguments.of(cp1252, us_ascii, true), + Arguments.of(cp1252, iso_8859_1, false), + Arguments.of(cp1252, iso_8859_15, false), + Arguments.of(cp1252, utf_8, false), + Arguments.of(cp1252, utf_16be, false), + Arguments.of(cp1252, cp1252, true) + ); + } } diff --git a/test/jdk/java/nio/charset/Charset/EmptyCharsetName.java b/test/jdk/java/nio/charset/Charset/EmptyCharsetName.java deleted file mode 100644 index 93797622553..00000000000 --- a/test/jdk/java/nio/charset/Charset/EmptyCharsetName.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* @test - * @bug 4786884 - * @summary Ensure that passing the empty string to Charset methods and - * constructors causes an IllegalArgumentException to be thrown - */ - -import java.io.*; -import java.nio.*; -import java.nio.charset.*; - - -public class EmptyCharsetName { - - static abstract class Test { - - public abstract void go() throws Exception; - - Test() throws Exception { - try { - go(); - } catch (Exception x) { - if (x instanceof IllegalCharsetNameException) { - System.err.println("Thrown as expected: " + x); - return; - } - throw new Exception("Incorrect exception: " - + x.getClass().getName(), - x); - } - throw new Exception("No exception thrown"); - } - - } - - public static void main(String[] args) throws Exception { - - new Test() { - public void go() throws Exception { - Charset.forName(""); - }}; - new Test() { - public void go() throws Exception { - Charset.isSupported(""); - }}; - new Test() { - public void go() throws Exception { - new Charset("", new String[] { }) { - public CharsetDecoder newDecoder() { - return null; - } - public CharsetEncoder newEncoder() { - return null; - } - public boolean contains(Charset cs) { - return false; - } - }; - }}; - } - -} diff --git a/test/jdk/java/nio/charset/Charset/EncDec.java b/test/jdk/java/nio/charset/Charset/EncDec.java index b0d2ccd92ec..324418ad074 100644 --- a/test/jdk/java/nio/charset/Charset/EncDec.java +++ b/test/jdk/java/nio/charset/Charset/EncDec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,23 +23,42 @@ /* @test * @summary Unit test for encode/decode convenience methods + * @run junit EncDec */ +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.util.stream.Stream; -import java.nio.*; -import java.nio.charset.*; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; public class EncDec { - public static void main(String[] args) throws Exception { - String s = "Hello, world!"; + /** + * Test that the input String is the same after round tripping + * the Charset.encode() and Charset.decode() methods. + */ + @ParameterizedTest + @MethodSource("stringProvider") + public void roundTripTest(String pre) { ByteBuffer bb = ByteBuffer.allocate(100); - bb.put(Charset.forName("ISO-8859-15").encode(s)).flip(); - String t = Charset.forName("UTF-8").decode(bb).toString(); - System.err.println(t); - if (!t.equals(s)) - throw new Exception("Mismatch: " + s + " != " + t); + Charset preCs = Charset.forName("ISO-8859-15"); + if (!preCs.canEncode()) { + throw new RuntimeException("Error: Trying to test encode and " + + "decode methods on a charset that does not support encoding"); + } + bb.put(preCs.encode(pre)).flip(); + String post = Charset.forName("UTF-8").decode(bb).toString(); + assertEquals(pre, post, "Mismatch after encoding + decoding, :"); } + static Stream stringProvider() { + return Stream.of( + "Hello, world!", + "apple, banana, orange", + "car, truck, horse"); + } } diff --git a/test/jdk/java/nio/charset/Charset/IllegalCharsetName.java b/test/jdk/java/nio/charset/Charset/IllegalCharsetName.java index dd7c68c9782..266801cf52b 100644 --- a/test/jdk/java/nio/charset/Charset/IllegalCharsetName.java +++ b/test/jdk/java/nio/charset/Charset/IllegalCharsetName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,46 +22,71 @@ */ /* @test - * @bug 6330020 8184665 + * @bug 4786884 6330020 8184665 * @summary Ensure Charset.forName/isSupport throws the correct exception * if the charset names passed in are illegal. + * @run junit IllegalCharsetName */ -import java.nio.charset.*; +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.CharsetEncoder; +import java.nio.charset.IllegalCharsetNameException; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertThrows; public class IllegalCharsetName { - public static void main(String[] args) throws Exception { - String[] illegalNames = { - ".", - "_", - ":", - "-", - ".name", - "_name", - ":name", - "-name", - "name*name", - "name?name" - }; - for (int i = 0; i < illegalNames.length; i++) { - try { - Charset.forName(illegalNames[i]); - throw new Exception("Charset.forName(): No exception thrown"); - } catch (IllegalCharsetNameException x) { //expected - } - try { - Charset.isSupported(illegalNames[i]); - throw new Exception("Charset.isSupported(): No exception thrown"); - } catch (IllegalCharsetNameException x) { //expected - } - } + // Charset.forName and Charset.isSupported should throw an + // IllegalCharsetNameException when passed an illegal name + @ParameterizedTest + @MethodSource("illegalNames") + public void illegalCharsetsTest(String name) { + assertThrows(IllegalCharsetNameException.class, + () -> Charset.forName(name)); + assertThrows(IllegalCharsetNameException.class, + () -> Charset.forName(name)); + } + + // Charset.forName, Charset.isSupported, and the Charset constructor should + // throw an IllegalCharsetNameException when passed an empty name + @Test + public void emptyCharsetsTest() { + assertThrows(IllegalCharsetNameException.class, + () -> Charset.forName("")); + assertThrows(IllegalCharsetNameException.class, + () -> Charset.forName("")); + assertThrows(IllegalCharsetNameException.class, + () -> new Charset("", new String[]{}) { + @Override + public boolean contains(Charset cs) { + return false; + } + + @Override + public CharsetDecoder newDecoder() { + return null; + } - // Standard charsets may bypass alias checking during startup, test that - // they're all well-behaved as a sanity test - checkAliases(StandardCharsets.ISO_8859_1); - checkAliases(StandardCharsets.US_ASCII); - checkAliases(StandardCharsets.UTF_8); + @Override + public CharsetEncoder newEncoder() { + return null; + } + }); + } + + // Standard charsets may bypass alias checking during startup, test that + // they're all well-behaved as a sanity test + @Test + public void aliasTest() { + for (Charset cs : Charset.availableCharsets().values()) { + checkAliases(cs); + } } private static void checkAliases(Charset cs) { @@ -70,4 +95,19 @@ private static void checkAliases(Charset cs) { Charset.isSupported(alias); } } + + static Stream illegalNames() { + return Stream.of( + ".", + "_", + ":", + "-", + ".name", + "_name", + ":name", + "-name", + "name*name", + "name?name" + ); + } } diff --git a/test/jdk/java/nio/charset/Charset/NullCharsetName.java b/test/jdk/java/nio/charset/Charset/NullCharsetName.java index 591fbf14cdf..a6b3a952215 100644 --- a/test/jdk/java/nio/charset/Charset/NullCharsetName.java +++ b/test/jdk/java/nio/charset/Charset/NullCharsetName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2023 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,29 +24,21 @@ /* @test * @bug 4448594 * @summary Ensure passing null to Charset.forName throws the correct exception + * @run junit NullCharsetName */ -import java.io.*; -import java.nio.*; -import java.nio.charset.*; -import java.util.*; +import java.nio.charset.Charset; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; public class NullCharsetName { - public static void main(String[] args) throws Exception { - try { - Charset.forName(null); - } catch (Exception x) { - if (x instanceof IllegalArgumentException) { - System.err.println("Thrown as expected: " + x); - return; - } - throw new Exception("Incorrect exception: " - + x.getClass().getName(), - x); - } - throw new Exception("No exception thrown"); + // Charset.forName should throw an exception when passed null + @Test + public void nullCharsetTest() { + assertThrows(IllegalArgumentException.class, + () -> Charset.forName(null)); } - } diff --git a/test/jdk/java/nio/charset/Charset/RegisteredCharsets.java b/test/jdk/java/nio/charset/Charset/RegisteredCharsets.java index 495d2a32bcd..c4a9853547b 100644 --- a/test/jdk/java/nio/charset/Charset/RegisteredCharsets.java +++ b/test/jdk/java/nio/charset/Charset/RegisteredCharsets.java @@ -26,1288 +26,1328 @@ 6911753 8071447 8186751 8242541 8260265 8301119 * @summary Check that registered charsets are actually registered * @modules jdk.charsets - * @run main RegisteredCharsets - * @run main/othervm -Djdk.charset.GB18030=2000 RegisteredCharsets + * @run junit RegisteredCharsets + * @run junit/othervm -Djdk.charset.GB18030=2000 RegisteredCharsets */ -import java.nio.charset.*; +import java.nio.charset.Charset; +import java.nio.charset.UnsupportedCharsetException; +import java.util.stream.Stream; -public class RegisteredCharsets { +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; - static String [] ianaRegistered = { - "US-ASCII", "UTF8", "Big5", "EUC-JP", - "GBK", "GB18030", "ISO-2022-KR", "ISO-2022-JP", - "GB2312", // IANA preferred name for "EUC-CN" - "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", - "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", - "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", - "ISO-8859-13", "ISO-8859-15", "ISO-8859-16", - "windows-1251", - "windows-1252", "windows-1253", "windows-1254", - "windows-1255", "windows-1256", "windows-31j", - "Shift_JIS", "JIS_X0201", "JIS_X0212-1990", - "TIS-620", "Big5-HKSCS", - "ISO-2022-CN", - "IBM850", - "IBM852", - "IBM855", - "IBM857", - "IBM860", - "IBM861", - "IBM862", - "IBM863", - "IBM864", - "IBM865", - "IBM866", - "IBM868", - "IBM869", - "IBM437", - "IBM775", - "IBM037", - "IBM1026", - "IBM273", - "IBM277", - "IBM278", - "IBM280", - "IBM284", - "IBM285", - "IBM297", - "IBM420", - "IBM424", - "IBM500", - "IBM-Thai", - "IBM870", - "IBM871", - "IBM918", - "IBM1047", - "IBM01140", - "IBM01141", - "IBM01142", - "IBM01143", - "IBM01144", - "IBM01145", - "IBM01146", - "IBM01147", - "IBM01148", - "IBM01149", - "IBM00858" }; - - static String [] ianaUnRegistered = { - "x-EUC-TW", "x-ISCII91", - "x-windows-949", "x-windows-950", - "x-mswin-936", "x-JIS0208", - "x-ISO-8859-11", - "x-windows-874", - "x-PCK", "x-JISAutoDetect", "x-Johab", - "x-MS950-HKSCS", - "x-Big5-Solaris", - "x-ISO-2022-CN-CNS", - "x-ISO-2022-CN-GB", - "x-MacArabic", - "x-MacCentralEurope", - "x-MacCroatian", - "x-MacCyrillic", - "x-MacDingbat", - "x-MacGreek", - "x-MacHebrew", - "x-MacIceland", - "x-MacRoman", - "x-MacRomania", - "x-MacSymbol", - "x-MacThai", - "x-MacTurkish", - "x-MacUkraine", - "x-IBM942", - "x-IBM942C", - "x-IBM943", - "x-IBM943C", - "x-IBM948", - "x-IBM950", - "x-IBM930", - "x-IBM935", - "x-IBM937", - "x-IBM856", - "x-IBM874", - "x-IBM737", - "x-IBM1006", - "x-IBM1046", - "x-IBM1098", - "x-IBM1025", - "x-IBM1112", - "x-IBM1122", - "x-IBM1123", - "x-IBM1124", - "x-IBM1129", - "x-IBM1166", - "x-IBM875", - "x-IBM921", - "x-IBM922", - "x-IBM1097", - "x-IBM949", - "x-IBM949C", - "x-IBM939", - "x-IBM933", - "x-IBM1381", - "x-IBM1383", - "x-IBM970", - "x-IBM964", - "x-IBM33722", - "x-IBM1006", - "x-IBM1046", - "x-IBM1097", - "x-IBM1098", - "x-IBM1112", - "x-IBM1122", - "x-IBM1123", - "x-IBM1124", - "x-IBM33722", - "x-IBM737", - "x-IBM856", - "x-IBM874", - "x-IBM875", - "x-IBM922", - "x-IBM933", - "x-IBM964" }; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; - static void check(String csn, boolean testRegistered) throws Exception { - if (!Charset.forName(csn).isRegistered() && testRegistered) - throw new Exception("Not registered: " + csn); - else if (Charset.forName(csn).isRegistered() && !testRegistered) - throw new Exception("Registered: " + csn + "should be unregistered"); +public class RegisteredCharsets { + + // Charset.forName should throw an exception when passed "default" + @Test + public void defaultCharsetTest() { + assertThrows(UnsupportedCharsetException.class, + () -> Charset.forName("default")); } - static void aliasCheck(String canonicalName, String[] aliasNames) throws Exception - { - for (int k = 0; k < aliasNames.length; k++ ) { - Charset cs = Charset.forName(aliasNames[k]); - if (!cs.name().equals(canonicalName)) { - throw new Exception("Unexpected Canonical name " + canonicalName); - } + /** + * Tests that the aliases of the input String convert + * to the same Charset. This is validated by ensuring the input String + * and Charset.name() values are equal. + */ + @ParameterizedTest + @MethodSource("aliases") + public void testAliases(String canonicalName, String[] aliasNames) { + for (String aliasName : aliasNames) { + Charset cs = Charset.forName(aliasName); + assertEquals(cs.name(), canonicalName); } } - public static void main(String[] args) throws Exception { + /** + * Tests charsets to ensure that they are registered in the + * IANA Charset Registry. + */ + @ParameterizedTest + @MethodSource("ianaRegistered") + public void registeredTest(String cs) throws Exception { + check(cs, true); + } - for (int i = 0; i < ianaRegistered.length ; i++) - check(ianaRegistered[i], true); + /** + * Tests charsets to ensure that they are NOT registered in the + * IANA Charset Registry. + */ + @ParameterizedTest + @MethodSource("ianaUnregistered") + public void unregisteredTest(String cs) throws Exception { + check(cs, false); + } - for (int i = 0; i < ianaUnRegistered.length ; i++) - check(ianaUnRegistered[i], false); + /** + * Helper method which checks if a charset is registered and whether + * it should be. + */ + static void check(String csn, boolean testRegistered) throws Exception { + if (!Charset.forName(csn).isRegistered() && testRegistered) { + throw new Exception("Not registered: " + csn); + } + else if (Charset.forName(csn).isRegistered() && !testRegistered) { + throw new Exception("Registered: " + csn + "should be unregistered"); + } + } + + // See https://www.iana.org/assignments/character-sets/character-sets.xhtml + private static Stream ianaRegistered() { + return Stream.of( + "US-ASCII", "UTF8", "Big5", "EUC-JP", + "GBK", "GB18030", "ISO-2022-KR", "ISO-2022-JP", + "GB2312", // IANA preferred name for "EUC-CN" + "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", + "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", + "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", + "ISO-8859-13", "ISO-8859-15", "ISO-8859-16", + "windows-1251", + "windows-1252", "windows-1253", "windows-1254", + "windows-1255", "windows-1256", "windows-31j", + "Shift_JIS", "JIS_X0201", "JIS_X0212-1990", + "TIS-620", "Big5-HKSCS", + "ISO-2022-CN", + "IBM850", + "IBM852", + "IBM855", + "IBM857", + "IBM860", + "IBM861", + "IBM862", + "IBM863", + "IBM864", + "IBM865", + "IBM866", + "IBM868", + "IBM869", + "IBM437", + "IBM775", + "IBM037", + "IBM1026", + "IBM273", + "IBM277", + "IBM278", + "IBM280", + "IBM284", + "IBM285", + "IBM297", + "IBM420", + "IBM424", + "IBM500", + "IBM-Thai", + "IBM870", + "IBM871", + "IBM918", + "IBM1047", + "IBM01140", + "IBM01141", + "IBM01142", + "IBM01143", + "IBM01144", + "IBM01145", + "IBM01146", + "IBM01147", + "IBM01148", + "IBM01149", + "IBM00858" + ); + } + private static Stream ianaUnregistered() { + return Stream.of( + "x-EUC-TW", "x-ISCII91", + "x-windows-949", "x-windows-950", + "x-mswin-936", "x-JIS0208", + "x-ISO-8859-11", + "x-windows-874", + "x-PCK", "x-JISAutoDetect", "x-Johab", + "x-MS950-HKSCS", + "x-Big5-Solaris", + "x-ISO-2022-CN-CNS", + "x-ISO-2022-CN-GB", + "x-MacArabic", + "x-MacCentralEurope", + "x-MacCroatian", + "x-MacCyrillic", + "x-MacDingbat", + "x-MacGreek", + "x-MacHebrew", + "x-MacIceland", + "x-MacRoman", + "x-MacRomania", + "x-MacSymbol", + "x-MacThai", + "x-MacTurkish", + "x-MacUkraine", + "x-IBM942", + "x-IBM942C", + "x-IBM943", + "x-IBM943C", + "x-IBM948", + "x-IBM950", + "x-IBM930", + "x-IBM935", + "x-IBM937", + "x-IBM856", + "x-IBM874", + "x-IBM737", + "x-IBM1006", + "x-IBM1046", + "x-IBM1098", + "x-IBM1025", + "x-IBM1112", + "x-IBM1122", + "x-IBM1123", + "x-IBM1124", + "x-IBM1129", + "x-IBM1166", + "x-IBM875", + "x-IBM921", + "x-IBM922", + "x-IBM1097", + "x-IBM949", + "x-IBM949C", + "x-IBM939", + "x-IBM933", + "x-IBM1381", + "x-IBM1383", + "x-IBM970", + "x-IBM964", + "x-IBM33722", + "x-IBM1006", + "x-IBM1046", + "x-IBM1097", + "x-IBM1098", + "x-IBM1112", + "x-IBM1122", + "x-IBM1123", + "x-IBM1124", + "x-IBM33722", + "x-IBM737", + "x-IBM856", + "x-IBM874", + "x-IBM875", + "x-IBM922", + "x-IBM933", + "x-IBM964" + ); + } + + private static Stream aliases() { // Check aliases registered with IANA for all NIO supported // Charset implementations. // // The aliases below are in sync with the IANA registered charset // document at: http://www.iana.org/assignments/character-sets // Last updated 7/25/2002 - - aliasCheck("US-ASCII", - new String[] {"ascii","ANSI_X3.4-1968", - "iso-ir-6","ANSI_X3.4-1986", "ISO_646.irv:1991", - "ASCII", "ISO646-US","us","IBM367","cp367", - "csASCII"}); - - aliasCheck("UTF-8", - new String[] { - "UTF8", - "unicode-1-1-utf-8" - }); - - aliasCheck("UTF-16", - new String[] { - "UTF_16", - "utf16" - }); - - aliasCheck("UTF-16BE", - new String[] { - "UTF_16BE", - "ISO-10646-UCS-2", - "X-UTF-16BE", - "UnicodeBigUnmarked" - }); - - aliasCheck("UTF-16LE", - new String[] { - "UTF_16LE", - "X-UTF-16LE", - "UnicodeLittleUnmarked" - }); - - aliasCheck("Big5", - new String[] { - "csBig5" - }); - - aliasCheck("Big5-HKSCS", - new String[] { - "Big5_HKSCS", - "big5hk", - "big5-hkscs", - "big5hkscs" - }); - - aliasCheck("x-MS950-HKSCS", - new String[] { - "MS950_HKSCS" - }); - - aliasCheck("GB18030", - "2000".equals(System.getProperty("jdk.charset.GB18030")) ? - new String[] { - "gb18030-2000" - } : - new String[] { - "gb18030-2022" - }); - - aliasCheck("ISO-2022-KR", new String[] {"csISO2022KR"}); - aliasCheck("ISO-2022-JP", new String[] {"csISO2022JP"}); - aliasCheck("EUC-KR", new String[] { "csEUCKR"}); - aliasCheck("ISO-8859-1", - new String[] { - - // IANA aliases - "iso-ir-100", - "ISO_8859-1", - "latin1", - "l1", - "IBM819", - "cp819", - "csISOLatin1", - - // JDK historical aliases - "819", - "IBM-819", - "ISO8859_1", - "ISO_8859-1:1987", - "ISO_8859_1", - "8859_1", - "ISO8859-1", - - }); - - aliasCheck("ISO-8859-2", - new String[] { - "ISO_8859-2", - "ISO_8859-2:1987", - "iso-ir-101", - "latin2", - "l2", - "8859_2", - "iso_8859-2:1987", - "iso8859-2", - "ibm912", - "ibm-912", - "cp912", - "912", - "csISOLatin2"}); - - aliasCheck("ISO-8859-3", - new String[] {"latin3", - "ISO_8859-3:1988", - "iso-ir-109", - "l3", - "8859_3", - "iso_8859-3:1988", - "iso8859-3", - "ibm913", - "ibm-913", - "cp913", - "913", - "csISOLatin3"}); - - aliasCheck("ISO-8859-4", - new String[] {"csISOLatin4", - "ISO_8859-4:1988", - "iso-ir-110", - "latin4", - "8859_4", - "iso_8859-4:1988", - "iso8859-4", - "ibm914", - "ibm-914", - "cp914", - "914", - "l4"}); - - aliasCheck("ISO-8859-5", - new String[] { - "iso8859_5", // JDK historical - "8859_5", - "iso-ir-144", - "ISO_8859-5", - "ISO_8859-5:1988", - "ISO8859-5", - "cyrillic", - "ibm915", - "ibm-915", - "915", - "cp915", - "csISOLatinCyrillic" - }); - - aliasCheck("ISO-8859-6", - new String[] {"ISO_8859-6:1987", - "iso-ir-127", - "ISO_8859-6", - "ECMA-114", - "ASMO-708", - "arabic", - "8859_6", - "iso_8859-6:1987", - "iso8859-6", - "ibm1089", - "ibm-1089", - "cp1089", - "1089", - "csISOLatinArabic"}); - - aliasCheck("ISO-8859-7", - new String[] {"ISO_8859-7:1987", - "iso-ir-126", - "ISO_8859-7", - "ELOT_928", - "ECMA-118", - "greek", - "greek8", - "8859_7", - "iso_8859-7:1987", - "iso8859-7", - "ibm813", - "ibm-813", - "cp813", - "813", - "csISOLatinGreek"}); - - aliasCheck("ISO-8859-8", - new String[] { - "ISO_8859-8:1988", - "iso-ir-138", - "ISO_8859-8", - "hebrew", - "8859_8", - "iso_8859-8:1988", - "iso8859-8", - "ibm916", - "ibm-916", - "cp916", - "916", - "csISOLatinHebrew"}); - - aliasCheck("ISO-8859-9", - new String[] {"ISO_8859-9:1989", - "iso-ir-148", - "ISO_8859-9", - "latin5", - "l5", - "8859_9", - "iso8859-9", - "ibm920", - "ibm-920", - "cp920", - "920", - "csISOLatin5"}); - - aliasCheck("ISO-8859-13", - new String[] { - "iso8859_13", // JDK historical - "iso_8859-13", - "8859_13", - "ISO8859-13" - }); - - aliasCheck("ISO-8859-15", - new String[] { - // IANA alias - "ISO_8859-15", - "Latin-9", - "csISO885915", - // JDK historical aliases - "8859_15", - "ISO-8859-15", - "ISO_8859-15", - "ISO8859-15", - "ISO8859_15", - "IBM923", - "IBM-923", - "cp923", - "923", - "LATIN0", - "LATIN9", - "L9", - "csISOlatin0", - "csISOlatin9", - "ISO8859_15_FDIS" - }); - - aliasCheck("ISO-8859-16", - new String[] { - "iso-ir-226", - "ISO_8859-16:2001", - "ISO_8859-16", - "ISO8859_16", - "latin10", - "l10", - "csISO885916" - }); - - aliasCheck("JIS_X0212-1990", - new String[] { - "iso-ir-159", - "csISO159JISX02121990"}); - - aliasCheck("JIS_X0201", - new String[]{ - "X0201", - "csHalfWidthKatakana"}); - - aliasCheck("KOI8-R", - new String[] { - "KOI8_R", - "csKOI8R"}); - - aliasCheck("GBK", - new String[] { - "windows-936"}); - - aliasCheck("Shift_JIS", - new String[] { - "MS_Kanji", - "csShiftJIS"}); - - aliasCheck("EUC-JP", - new String[] { - "Extended_UNIX_Code_Packed_Format_for_Japanese", - "csEUCPkdFmtJapanese"}); - - aliasCheck("Big5", new String[] {"csBig5"}); - - aliasCheck("windows-31j", new String[] {"csWindows31J"}); - - aliasCheck("x-iso-8859-11", - new String[] { "iso-8859-11", "iso8859_11" }); - - aliasCheck("windows-1250", - new String[] { - "cp1250", - "cp5346" - }); - - aliasCheck("windows-1251", - new String[] { - "cp1251", - "cp5347", - "ansi-1251" - }); - - aliasCheck("windows-1252", - new String[] { - "cp1252", - "cp5348" - }); - - aliasCheck("windows-1253", - new String[] { - "cp1253", - "cp5349" - }); - - aliasCheck("windows-1254", - new String[] { - "cp1254", - "cp5350" - }); - - aliasCheck("windows-1255", - new String[] { - "cp1255" - }); - - aliasCheck("windows-1256", - new String[] { - "cp1256" - }); - - aliasCheck("windows-1257", - new String[] { - "cp1257", - "cp5353" - }); - - aliasCheck("windows-1258", - new String[] { - "cp1258" - }); - - aliasCheck("x-windows-874", - new String[] { - "ms874", "ms-874", "windows-874" }); - - aliasCheck("GB2312", - new String[] { - "x-EUC-CN", - "gb2312-80", - "gb2312-1980", - "euc-cn", - "euccn" }); - - aliasCheck("x-IBM942" , - new String[] { - "cp942", // JDK historical - "ibm942", - "ibm-942", - "942" - }); - - aliasCheck("x-IBM942C" , - new String[] { - "cp942C", // JDK historical - "ibm942C", - "ibm-942C", - "942C" - } ); - - aliasCheck("x-IBM943" , - new String[] { - "cp943", // JDK historical - "ibm943", - "ibm-943", - "943" - } ); - - aliasCheck("x-IBM943C" , - new String[] { - "cp943c", // JDK historical - "ibm943C", - "ibm-943C", - "943C" - } ); - - aliasCheck("x-IBM948" , - new String[] { - "cp948", // JDK historical - "ibm948", - "ibm-948", - "948" - } ); - - aliasCheck("x-IBM950" , - new String[] { - "cp950", // JDK historical - "ibm950", - "ibm-950", - "950" - } ); - - aliasCheck("x-IBM930" , - new String[] { - "cp930", // JDK historical - "ibm930", - "ibm-930", - "930" - } ); - - aliasCheck("x-IBM935" , - new String[] { - "cp935", // JDK historical - "ibm935", - "ibm-935", - "935" - } ); - - aliasCheck("x-IBM937" , - new String[] { - "cp937", // JDK historical - "ibm937", - "ibm-937", - "937" - } ); - - aliasCheck("IBM850" , - new String[] { - "cp850", // JDK historical - "ibm-850", - "ibm850", - "850", - "cspc850multilingual" - } ); - - aliasCheck("IBM852" , - new String[] { - "cp852", // JDK historical - "ibm852", - "ibm-852", - "852", - "csPCp852" - } ); - - aliasCheck("IBM855" , - new String[] { - "cp855", // JDK historical - "ibm-855", - "ibm855", - "855", - "cspcp855" - } ); - - aliasCheck("x-IBM856" , - new String[] { - "cp856", // JDK historical - "ibm-856", - "ibm856", - "856" - } ); - - aliasCheck("IBM857" , - new String[] { - "cp857", // JDK historical - "ibm857", - "ibm-857", - "857", - "csIBM857" - } ); - - aliasCheck("IBM860" , - new String[] { - "cp860", // JDK historical - "ibm860", - "ibm-860", - "860", - "csIBM860" - } ); - aliasCheck("IBM861" , - new String[] { - "cp861", // JDK historical - "ibm861", - "ibm-861", - "861", - "csIBM861" - } ); - - aliasCheck("IBM862" , - new String[] { - "cp862", // JDK historical - "ibm862", - "ibm-862", - "862", - "csIBM862" - } ); - - aliasCheck("IBM863" , - new String[] { - "cp863", // JDK historical - "ibm863", - "ibm-863", - "863", - "csIBM863" - } ); - - aliasCheck("IBM864" , - new String[] { - "cp864", // JDK historical - "ibm864", - "ibm-864", - "864", - "csIBM864" - } ); - - aliasCheck("IBM865" , - new String[] { - "cp865", // JDK historical - "ibm865", - "ibm-865", - "865", - "csIBM865" - } ); - - aliasCheck("IBM866" , new String[] { - "cp866", // JDK historical - "ibm866", - "ibm-866", - "866", - "csIBM866" - } ); - aliasCheck("IBM868" , - new String[] { - "cp868", // JDK historical - "ibm868", - "ibm-868", - "868", - "cp-ar", - "csIBM868" - } ); - - aliasCheck("IBM869" , - new String[] { - "cp869", // JDK historical - "ibm869", - "ibm-869", - "869", - "cp-gr", - "csIBM869" - } ); - - aliasCheck("IBM437" , - new String[] { - "cp437", // JDK historical - "ibm437", - "ibm-437", - "437", - "cspc8codepage437", - "windows-437" - } ); - - aliasCheck("x-IBM874" , - new String[] { - "cp874", // JDK historical - "ibm874", - "ibm-874", - "874" - } ); - aliasCheck("x-IBM737" , - new String[] { - "cp737", // JDK historical - "ibm737", - "ibm-737", - "737" - } ); - - aliasCheck("IBM775" , - new String[] { - "cp775", // JDK historical - "ibm775", - "ibm-775", - "775" - } ); - - aliasCheck("x-IBM921" , - new String[] { - "cp921", // JDK historical - "ibm921", - "ibm-921", - "921" - } ); - - aliasCheck("x-IBM1006" , - new String[] { - "cp1006", // JDK historical - "ibm1006", - "ibm-1006", - "1006" - } ); - - aliasCheck("x-IBM1046" , - new String[] { - "cp1046", // JDK historical - "ibm1046", - "ibm-1046", - "1046" - } ); - - aliasCheck("IBM1047" , - new String[] { - "cp1047", // JDK historical - "ibm-1047", - "1047" - } ); - - aliasCheck("x-IBM1098" , - new String[] { - "cp1098", // JDK historical - "ibm1098", - "ibm-1098", - "1098", - } ); - - aliasCheck("IBM037" , - new String[] { - "cp037", // JDK historical - "ibm037", - "csIBM037", - "cs-ebcdic-cp-us", - "cs-ebcdic-cp-ca", - "cs-ebcdic-cp-wt", - "cs-ebcdic-cp-nl", - "ibm-037", - "ibm-37", - "cpibm37", - "037" - } ); - - aliasCheck("x-IBM1025" , - new String[] { - "cp1025", // JDK historical - "ibm1025", - "ibm-1025", - "1025" - } ); - - aliasCheck("IBM1026" , - new String[] { - "cp1026", // JDK historical - "ibm1026", - "ibm-1026", - "1026" - } ); - - aliasCheck("x-IBM1112" , - new String[] { - "cp1112", // JDK historical - "ibm1112", - "ibm-1112", - "1112" - } ); - - aliasCheck("x-IBM1122" , - new String[] { - "cp1122", // JDK historical - "ibm1122", - "ibm-1122", - "1122" - } ); - - aliasCheck("x-IBM1123" , - new String[] { - "cp1123", // JDK historical - "ibm1123", - "ibm-1123", - "1123" - } ); - - aliasCheck("x-IBM1124" , - new String[] { - "cp1124", // JDK historical - "ibm1124", - "ibm-1124", - "1124" - } ); - - aliasCheck("x-IBM1129" , - new String[] { - "cp1129", // JDK historical - "ibm1129", - "ibm-1129", - "1129" - } ); - - aliasCheck("x-IBM1166" , - new String[] { - "cp1166", // JDK historical - "ibm1166", - "ibm-1166", - "1166" - } ); - - aliasCheck("IBM273" , - new String[] { - "cp273", // JDK historical - "ibm273", - "ibm-273", - "273" - } ); - - aliasCheck("IBM277" , - new String[] { - "cp277", // JDK historical - "ibm277", - "ibm-277", - "277" - } ); - - aliasCheck("IBM278" , - new String[] { - "cp278", // JDK historical - "ibm278", - "ibm-278", - "278", - "ebcdic-sv", - "ebcdic-cp-se", - "csIBM278" - } ); - - aliasCheck("IBM280" , - new String[] { - "cp280", // JDK historical - "ibm280", - "ibm-280", - "280" - } ); - - aliasCheck("IBM284" , - new String[] { - "cp284", // JDK historical - "ibm284", - "ibm-284", - "284", - "csIBM284", - "cpibm284" - } ); - - aliasCheck("IBM285" , - new String[] { - "cp285", // JDK historical - "ibm285", - "ibm-285", - "285", - "ebcdic-cp-gb", - "ebcdic-gb", - "csIBM285", - "cpibm285" - } ); - - aliasCheck("IBM297" , - new String[] { - "cp297", // JDK historical - "ibm297", - "ibm-297", - "297", - "ebcdic-cp-fr", - "cpibm297", - "csIBM297", - } ); - - aliasCheck("IBM420" , - new String[] { - "cp420", // JDK historical - "ibm420", - "ibm-420", - "ebcdic-cp-ar1", - "420", - "csIBM420" - } ); - - aliasCheck("IBM424" , - new String[] { - "cp424", // JDK historical - "ibm424", - "ibm-424", - "424", - "ebcdic-cp-he", - "csIBM424" - } ); - - aliasCheck("IBM500" , - new String[] { - "cp500", // JDK historical - "ibm500", - "ibm-500", - "500", - "ebcdic-cp-ch", - "ebcdic-cp-bh", - "csIBM500" - } ); - - aliasCheck("IBM-Thai" , - new String[] { - "cp838", // JDK historical - "ibm838", - "ibm-838", - "ibm838", - "838" - } ); - - aliasCheck("IBM870" , - new String[] { - "cp870", // JDK historical - "ibm870", - "ibm-870", - "870", - "ebcdic-cp-roece", - "ebcdic-cp-yu", - "csIBM870" - } ); - - aliasCheck("IBM871" , - new String[] { - "cp871", // JDK historical - "ibm871", - "ibm-871", - "871", - "ebcdic-cp-is", - "csIBM871" - } ); - - aliasCheck("x-IBM875" , - new String[] { - "cp875", // JDK historical - "ibm875", - "ibm-875", - "875" - } ); - - aliasCheck("IBM918" , - new String[] { - "cp918", // JDK historical - "ibm-918", - "918", - "ebcdic-cp-ar2" - } ); - - aliasCheck("x-IBM922" , - new String[] { - "cp922", // JDK historical - "ibm922", - "ibm-922", - "922" - } ); - - aliasCheck("x-IBM1097" , - new String[] { - "cp1097", // JDK historical - "ibm1097", - "ibm-1097", - "1097" - } ); - - aliasCheck("x-IBM949" , - new String[] { - "cp949", // JDK historical - "ibm949", - "ibm-949", - "949" - } ); - - aliasCheck("x-IBM949C" , - new String[] { - "cp949C", // JDK historical - "ibm949C", - "ibm-949C", - "949C" - } ); - - aliasCheck("x-IBM939" , - new String[] { - "cp939", // JDK historical - "ibm939", - "ibm-939", - "939" - } ); - - aliasCheck("x-IBM933" , - new String[] { - "cp933", // JDK historical - "ibm933", - "ibm-933", - "933" - } ); - - aliasCheck("x-IBM1381" , - new String[] { - "cp1381", // JDK historical - "ibm1381", - "ibm-1381", - "1381" - } ); - - aliasCheck("x-IBM1383" , - new String[] { - "cp1383", // JDK historical - "ibm1383", - "ibm-1383", - "1383" - } ); - - aliasCheck("x-IBM970" , - new String[] { - "cp970", // JDK historical - "ibm970", - "ibm-970", - "ibm-eucKR", - "970" - } ); - - aliasCheck("x-IBM964" , - new String[] { - "cp964", // JDK historical - "ibm964", - "ibm-964", - "964" - } ); - - aliasCheck("x-IBM33722" , - new String[] { - "cp33722", // JDK historical - "ibm33722", - "ibm-33722", - "ibm-5050", // from IBM alias list - "ibm-33722_vascii_vpua", // from IBM alias list - "33722" - } ); - - aliasCheck("IBM01140" , - new String[] { - "cp1140", // JDK historical - "ccsid01140", - "cp01140", - // "ebcdic-us-037+euro" - } ); - - aliasCheck("IBM01141" , - new String[] { - "cp1141", // JDK historical - "ccsid01141", - "cp01141", - // "ebcdic-de-273+euro" - } ); - - aliasCheck("IBM01142" , - new String[] { - "cp1142", // JDK historical - "ccsid01142", - "cp01142", - // "ebcdic-no-277+euro", - // "ebcdic-dk-277+euro" - } ); - - aliasCheck("IBM01143" , - new String[] { - "cp1143", // JDK historical - "ccsid01143", - "cp01143", - // "ebcdic-fi-278+euro", - // "ebcdic-se-278+euro" - } ); - - aliasCheck("IBM01144" , - new String[] { - "cp1144", // JDK historical - "ccsid01144", - "cp01144", - // "ebcdic-it-280+euro" - } ); - - aliasCheck("IBM01145" , - new String[] { - "cp1145", // JDK historical - "ccsid01145", - "cp01145", - // "ebcdic-es-284+euro" - } ); - - aliasCheck("IBM01146" , - new String[] { - "cp1146", // JDK historical - "ccsid01146", - "cp01146", - // "ebcdic-gb-285+euro" - } ); - - aliasCheck("IBM01147" , - new String[] { - "cp1147", // JDK historical - "ccsid01147", - "cp01147", - // "ebcdic-fr-277+euro" - } ); - - aliasCheck("IBM01148" , - new String[] { - "cp1148", // JDK historical - "ccsid01148", - "cp01148", - // "ebcdic-international-500+euro" - } ); - - aliasCheck("IBM01149" , - new String[] { - "cp1149", // JDK historical - "ccsid01149", - "cp01149", - // "ebcdic-s-871+euro" - } ); - - aliasCheck("IBM00858" , - new String[] { - "cp858", // JDK historical - "ccsid00858", - "cp00858", - // "PC-Multilingual-850+euro" - } ); - - aliasCheck("x-MacRoman", - new String[] { - "MacRoman" // JDK historical - }); - - aliasCheck("x-MacCentralEurope", - new String[] { - "MacCentralEurope" // JDK historical - }); - - aliasCheck("x-MacCroatian", - new String[] { - "MacCroatian" // JDK historical - }); - - - aliasCheck("x-MacCroatian", - new String[] { - "MacCroatian" // JDK historical - }); - - - aliasCheck("x-MacGreek", - new String[] { - "MacGreek" // JDK historical - }); - - aliasCheck("x-MacCyrillic", - new String[] { - "MacCyrillic" // JDK historical - }); - - aliasCheck("x-MacUkraine", - new String[] { - "MacUkraine" // JDK historical - }); - - aliasCheck("x-MacTurkish", - new String[] { - "MacTurkish" // JDK historical - }); - - aliasCheck("x-MacArabic", - new String[] { - "MacArabic" // JDK historical - }); - - aliasCheck("x-MacHebrew", - new String[] { - "MacHebrew" // JDK historical - }); - - aliasCheck("x-MacIceland", - new String[] { - "MacIceland" // JDK historical - }); - - aliasCheck("x-MacRomania", - new String[] { - "MacRomania" // JDK historical - }); - - aliasCheck("x-MacThai", - new String[] { - "MacThai" // JDK historical - }); - - aliasCheck("x-MacSymbol", - new String[] { - "MacSymbol" // JDK historical - }); - - aliasCheck("x-MacDingbat", - new String[] { - "MacDingbat" // JDK historical - }); - - // Check UnsupportedCharsetException is thrown for the name "default" - try { - Charset.forName("default"); - throw new RuntimeException("UnsupportedCharsetException was not thrown for Charset.forName(\"default\")"); - } catch (UnsupportedCharsetException uce) { - // success - } + return Stream.of( + Arguments.of("US-ASCII", + new String[] {"ascii","ANSI_X3.4-1968", + "iso-ir-6","ANSI_X3.4-1986", "ISO_646.irv:1991", + "ASCII", "ISO646-US","us","IBM367","cp367", + "csASCII"}), + + Arguments.of("UTF-8", + new String[] { + "UTF8", + "unicode-1-1-utf-8" + }), + + Arguments.of("UTF-16", + new String[] { + "UTF_16", + "utf16" + }), + + Arguments.of("UTF-16BE", + new String[] { + "UTF_16BE", + "ISO-10646-UCS-2", + "X-UTF-16BE", + "UnicodeBigUnmarked" + }), + + Arguments.of("UTF-16LE", + new String[] { + "UTF_16LE", + "X-UTF-16LE", + "UnicodeLittleUnmarked" + }), + + Arguments.of("Big5", + new String[] { + "csBig5" + }), + + Arguments.of("Big5-HKSCS", + new String[] { + "Big5_HKSCS", + "big5hk", + "big5-hkscs", + "big5hkscs" + }), + + Arguments.of("x-MS950-HKSCS", + new String[] { + "MS950_HKSCS" + }), + + Arguments.of("GB18030", + "2000".equals(System.getProperty("jdk.charset.GB18030")) ? + new String[] { + "gb18030-2000" + } : + new String[] { + "gb18030-2022" + }), + + Arguments.of("ISO-2022-KR", new String[] {"csISO2022KR"}), + Arguments.of("ISO-2022-JP", new String[] {"csISO2022JP"}), + Arguments.of("EUC-KR", new String[] { "csEUCKR"}), + Arguments.of("ISO-8859-1", + new String[] { + + // IANA aliases + "iso-ir-100", + "ISO_8859-1", + "latin1", + "l1", + "IBM819", + "cp819", + "csISOLatin1", + + // JDK historical aliases + "819", + "IBM-819", + "ISO8859_1", + "ISO_8859-1:1987", + "ISO_8859_1", + "8859_1", + "ISO8859-1", + + }), + + Arguments.of("ISO-8859-2", + new String[] { + "ISO_8859-2", + "ISO_8859-2:1987", + "iso-ir-101", + "latin2", + "l2", + "8859_2", + "iso_8859-2:1987", + "iso8859-2", + "ibm912", + "ibm-912", + "cp912", + "912", + "csISOLatin2"}), + + Arguments.of("ISO-8859-3", + new String[] {"latin3", + "ISO_8859-3:1988", + "iso-ir-109", + "l3", + "8859_3", + "iso_8859-3:1988", + "iso8859-3", + "ibm913", + "ibm-913", + "cp913", + "913", + "csISOLatin3"}), + + Arguments.of("ISO-8859-4", + new String[] {"csISOLatin4", + "ISO_8859-4:1988", + "iso-ir-110", + "latin4", + "8859_4", + "iso_8859-4:1988", + "iso8859-4", + "ibm914", + "ibm-914", + "cp914", + "914", + "l4"}), + + Arguments.of("ISO-8859-5", + new String[] { + "iso8859_5", // JDK historical + "8859_5", + "iso-ir-144", + "ISO_8859-5", + "ISO_8859-5:1988", + "ISO8859-5", + "cyrillic", + "ibm915", + "ibm-915", + "915", + "cp915", + "csISOLatinCyrillic" + }), + + Arguments.of("ISO-8859-6", + new String[] {"ISO_8859-6:1987", + "iso-ir-127", + "ISO_8859-6", + "ECMA-114", + "ASMO-708", + "arabic", + "8859_6", + "iso_8859-6:1987", + "iso8859-6", + "ibm1089", + "ibm-1089", + "cp1089", + "1089", + "csISOLatinArabic"}), + + Arguments.of("ISO-8859-7", + new String[] {"ISO_8859-7:1987", + "iso-ir-126", + "ISO_8859-7", + "ELOT_928", + "ECMA-118", + "greek", + "greek8", + "8859_7", + "iso_8859-7:1987", + "iso8859-7", + "ibm813", + "ibm-813", + "cp813", + "813", + "csISOLatinGreek"}), + + Arguments.of("ISO-8859-8", + new String[] { + "ISO_8859-8:1988", + "iso-ir-138", + "ISO_8859-8", + "hebrew", + "8859_8", + "iso_8859-8:1988", + "iso8859-8", + "ibm916", + "ibm-916", + "cp916", + "916", + "csISOLatinHebrew"}), + + Arguments.of("ISO-8859-9", + new String[] {"ISO_8859-9:1989", + "iso-ir-148", + "ISO_8859-9", + "latin5", + "l5", + "8859_9", + "iso8859-9", + "ibm920", + "ibm-920", + "cp920", + "920", + "csISOLatin5"}), + + Arguments.of("ISO-8859-13", + new String[] { + "iso8859_13", // JDK historical + "iso_8859-13", + "8859_13", + "ISO8859-13" + }), + + Arguments.of("ISO-8859-15", + new String[] { + // IANA alias + "ISO_8859-15", + "Latin-9", + "csISO885915", + // JDK historical aliases + "8859_15", + "ISO-8859-15", + "ISO_8859-15", + "ISO8859-15", + "ISO8859_15", + "IBM923", + "IBM-923", + "cp923", + "923", + "LATIN0", + "LATIN9", + "L9", + "csISOlatin0", + "csISOlatin9", + "ISO8859_15_FDIS" + }), + + Arguments.of("ISO-8859-16", + new String[] { + "iso-ir-226", + "ISO_8859-16:2001", + "ISO_8859-16", + "ISO8859_16", + "latin10", + "l10", + "csISO885916" + }), + + Arguments.of("JIS_X0212-1990", + new String[] { + "iso-ir-159", + "csISO159JISX02121990"}), + + Arguments.of("JIS_X0201", + new String[]{ + "X0201", + "csHalfWidthKatakana"}), + + Arguments.of("KOI8-R", + new String[] { + "KOI8_R", + "csKOI8R"}), + + Arguments.of("GBK", + new String[] { + "windows-936"}), + + Arguments.of("Shift_JIS", + new String[] { + "MS_Kanji", + "csShiftJIS"}), + + Arguments.of("EUC-JP", + new String[] { + "Extended_UNIX_Code_Packed_Format_for_Japanese", + "csEUCPkdFmtJapanese"}), + + Arguments.of("Big5", new String[] {"csBig5"}), + + Arguments.of("windows-31j", new String[] {"csWindows31J"}), + + Arguments.of("x-iso-8859-11", + new String[] { "iso-8859-11", "iso8859_11" }), + + Arguments.of("windows-1250", + new String[] { + "cp1250", + "cp5346" + }), + + Arguments.of("windows-1251", + new String[] { + "cp1251", + "cp5347", + "ansi-1251" + }), + + Arguments.of("windows-1252", + new String[] { + "cp1252", + "cp5348" + }), + + Arguments.of("windows-1253", + new String[] { + "cp1253", + "cp5349" + }), + + Arguments.of("windows-1254", + new String[] { + "cp1254", + "cp5350" + }), + + Arguments.of("windows-1255", + new String[] { + "cp1255" + }), + + Arguments.of("windows-1256", + new String[] { + "cp1256" + }), + + Arguments.of("windows-1257", + new String[] { + "cp1257", + "cp5353" + }), + + Arguments.of("windows-1258", + new String[] { + "cp1258" + }), + + Arguments.of("x-windows-874", + new String[] { + "ms874", "ms-874", "windows-874" }), + + Arguments.of("GB2312", + new String[] { + "x-EUC-CN", + "gb2312-80", + "gb2312-1980", + "euc-cn", + "euccn" }), + + Arguments.of("x-IBM942" , + new String[] { + "cp942", // JDK historical + "ibm942", + "ibm-942", + "942" + }), + + Arguments.of("x-IBM942C" , + new String[] { + "cp942C", // JDK historical + "ibm942C", + "ibm-942C", + "942C" + } ), + + Arguments.of("x-IBM943" , + new String[] { + "cp943", // JDK historical + "ibm943", + "ibm-943", + "943" + } ), + + Arguments.of("x-IBM943C" , + new String[] { + "cp943c", // JDK historical + "ibm943C", + "ibm-943C", + "943C" + } ), + + Arguments.of("x-IBM948" , + new String[] { + "cp948", // JDK historical + "ibm948", + "ibm-948", + "948" + } ), + + Arguments.of("x-IBM950" , + new String[] { + "cp950", // JDK historical + "ibm950", + "ibm-950", + "950" + } ), + + Arguments.of("x-IBM930" , + new String[] { + "cp930", // JDK historical + "ibm930", + "ibm-930", + "930" + } ), + + Arguments.of("x-IBM935" , + new String[] { + "cp935", // JDK historical + "ibm935", + "ibm-935", + "935" + } ), + + Arguments.of("x-IBM937" , + new String[] { + "cp937", // JDK historical + "ibm937", + "ibm-937", + "937" + } ), + + Arguments.of("IBM850" , + new String[] { + "cp850", // JDK historical + "ibm-850", + "ibm850", + "850", + "cspc850multilingual" + } ), + + Arguments.of("IBM852" , + new String[] { + "cp852", // JDK historical + "ibm852", + "ibm-852", + "852", + "csPCp852" + } ), + + Arguments.of("IBM855" , + new String[] { + "cp855", // JDK historical + "ibm-855", + "ibm855", + "855", + "cspcp855" + } ), + + Arguments.of("x-IBM856" , + new String[] { + "cp856", // JDK historical + "ibm-856", + "ibm856", + "856" + } ), + + Arguments.of("IBM857" , + new String[] { + "cp857", // JDK historical + "ibm857", + "ibm-857", + "857", + "csIBM857" + } ), + + Arguments.of("IBM860" , + new String[] { + "cp860", // JDK historical + "ibm860", + "ibm-860", + "860", + "csIBM860" + } ), + Arguments.of("IBM861" , + new String[] { + "cp861", // JDK historical + "ibm861", + "ibm-861", + "861", + "csIBM861" + } ), + + Arguments.of("IBM862" , + new String[] { + "cp862", // JDK historical + "ibm862", + "ibm-862", + "862", + "csIBM862" + } ), + + Arguments.of("IBM863" , + new String[] { + "cp863", // JDK historical + "ibm863", + "ibm-863", + "863", + "csIBM863" + } ), + + Arguments.of("IBM864" , + new String[] { + "cp864", // JDK historical + "ibm864", + "ibm-864", + "864", + "csIBM864" + } ), + + Arguments.of("IBM865" , + new String[] { + "cp865", // JDK historical + "ibm865", + "ibm-865", + "865", + "csIBM865" + } ), + + Arguments.of("IBM866" , new String[] { + "cp866", // JDK historical + "ibm866", + "ibm-866", + "866", + "csIBM866" + } ), + Arguments.of("IBM868" , + new String[] { + "cp868", // JDK historical + "ibm868", + "ibm-868", + "868", + "cp-ar", + "csIBM868" + } ), + + Arguments.of("IBM869" , + new String[] { + "cp869", // JDK historical + "ibm869", + "ibm-869", + "869", + "cp-gr", + "csIBM869" + } ), + + Arguments.of("IBM437" , + new String[] { + "cp437", // JDK historical + "ibm437", + "ibm-437", + "437", + "cspc8codepage437", + "windows-437" + } ), + + Arguments.of("x-IBM874" , + new String[] { + "cp874", // JDK historical + "ibm874", + "ibm-874", + "874" + } ), + Arguments.of("x-IBM737" , + new String[] { + "cp737", // JDK historical + "ibm737", + "ibm-737", + "737" + } ), + + Arguments.of("IBM775" , + new String[] { + "cp775", // JDK historical + "ibm775", + "ibm-775", + "775" + } ), + + Arguments.of("x-IBM921" , + new String[] { + "cp921", // JDK historical + "ibm921", + "ibm-921", + "921" + } ), + + Arguments.of("x-IBM1006" , + new String[] { + "cp1006", // JDK historical + "ibm1006", + "ibm-1006", + "1006" + } ), + + Arguments.of("x-IBM1046" , + new String[] { + "cp1046", // JDK historical + "ibm1046", + "ibm-1046", + "1046" + } ), + + Arguments.of("IBM1047" , + new String[] { + "cp1047", // JDK historical + "ibm-1047", + "1047" + } ), + + Arguments.of("x-IBM1098" , + new String[] { + "cp1098", // JDK historical + "ibm1098", + "ibm-1098", + "1098", + } ), + + Arguments.of("IBM037" , + new String[] { + "cp037", // JDK historical + "ibm037", + "csIBM037", + "cs-ebcdic-cp-us", + "cs-ebcdic-cp-ca", + "cs-ebcdic-cp-wt", + "cs-ebcdic-cp-nl", + "ibm-037", + "ibm-37", + "cpibm37", + "037" + } ), + + Arguments.of("x-IBM1025" , + new String[] { + "cp1025", // JDK historical + "ibm1025", + "ibm-1025", + "1025" + } ), + + Arguments.of("IBM1026" , + new String[] { + "cp1026", // JDK historical + "ibm1026", + "ibm-1026", + "1026" + } ), + + Arguments.of("x-IBM1112" , + new String[] { + "cp1112", // JDK historical + "ibm1112", + "ibm-1112", + "1112" + } ), + + Arguments.of("x-IBM1122" , + new String[] { + "cp1122", // JDK historical + "ibm1122", + "ibm-1122", + "1122" + } ), + + Arguments.of("x-IBM1123" , + new String[] { + "cp1123", // JDK historical + "ibm1123", + "ibm-1123", + "1123" + } ), + + Arguments.of("x-IBM1124" , + new String[] { + "cp1124", // JDK historical + "ibm1124", + "ibm-1124", + "1124" + } ), + + Arguments.of("x-IBM1129" , + new String[] { + "cp1129", // JDK historical + "ibm1129", + "ibm-1129", + "1129" + } ), + + Arguments.of("x-IBM1166" , + new String[] { + "cp1166", // JDK historical + "ibm1166", + "ibm-1166", + "1166" + } ), + + Arguments.of("IBM273" , + new String[] { + "cp273", // JDK historical + "ibm273", + "ibm-273", + "273" + } ), + + Arguments.of("IBM277" , + new String[] { + "cp277", // JDK historical + "ibm277", + "ibm-277", + "277" + } ), + + Arguments.of("IBM278" , + new String[] { + "cp278", // JDK historical + "ibm278", + "ibm-278", + "278", + "ebcdic-sv", + "ebcdic-cp-se", + "csIBM278" + } ), + + Arguments.of("IBM280" , + new String[] { + "cp280", // JDK historical + "ibm280", + "ibm-280", + "280" + } ), + + Arguments.of("IBM284" , + new String[] { + "cp284", // JDK historical + "ibm284", + "ibm-284", + "284", + "csIBM284", + "cpibm284" + } ), + + Arguments.of("IBM285" , + new String[] { + "cp285", // JDK historical + "ibm285", + "ibm-285", + "285", + "ebcdic-cp-gb", + "ebcdic-gb", + "csIBM285", + "cpibm285" + } ), + + Arguments.of("IBM297" , + new String[] { + "cp297", // JDK historical + "ibm297", + "ibm-297", + "297", + "ebcdic-cp-fr", + "cpibm297", + "csIBM297", + } ), + + Arguments.of("IBM420" , + new String[] { + "cp420", // JDK historical + "ibm420", + "ibm-420", + "ebcdic-cp-ar1", + "420", + "csIBM420" + } ), + + Arguments.of("IBM424" , + new String[] { + "cp424", // JDK historical + "ibm424", + "ibm-424", + "424", + "ebcdic-cp-he", + "csIBM424" + } ), + + Arguments.of("IBM500" , + new String[] { + "cp500", // JDK historical + "ibm500", + "ibm-500", + "500", + "ebcdic-cp-ch", + "ebcdic-cp-bh", + "csIBM500" + } ), + + Arguments.of("IBM-Thai" , + new String[] { + "cp838", // JDK historical + "ibm838", + "ibm-838", + "ibm838", + "838" + } ), + + Arguments.of("IBM870" , + new String[] { + "cp870", // JDK historical + "ibm870", + "ibm-870", + "870", + "ebcdic-cp-roece", + "ebcdic-cp-yu", + "csIBM870" + } ), + + Arguments.of("IBM871" , + new String[] { + "cp871", // JDK historical + "ibm871", + "ibm-871", + "871", + "ebcdic-cp-is", + "csIBM871" + } ), + + Arguments.of("x-IBM875" , + new String[] { + "cp875", // JDK historical + "ibm875", + "ibm-875", + "875" + } ), + + Arguments.of("IBM918" , + new String[] { + "cp918", // JDK historical + "ibm-918", + "918", + "ebcdic-cp-ar2" + } ), + + Arguments.of("x-IBM922" , + new String[] { + "cp922", // JDK historical + "ibm922", + "ibm-922", + "922" + } ), + + Arguments.of("x-IBM1097" , + new String[] { + "cp1097", // JDK historical + "ibm1097", + "ibm-1097", + "1097" + } ), + + Arguments.of("x-IBM949" , + new String[] { + "cp949", // JDK historical + "ibm949", + "ibm-949", + "949" + } ), + + Arguments.of("x-IBM949C" , + new String[] { + "cp949C", // JDK historical + "ibm949C", + "ibm-949C", + "949C" + } ), + + Arguments.of("x-IBM939" , + new String[] { + "cp939", // JDK historical + "ibm939", + "ibm-939", + "939" + } ), + + Arguments.of("x-IBM933" , + new String[] { + "cp933", // JDK historical + "ibm933", + "ibm-933", + "933" + } ), + + Arguments.of("x-IBM1381" , + new String[] { + "cp1381", // JDK historical + "ibm1381", + "ibm-1381", + "1381" + } ), + + Arguments.of("x-IBM1383" , + new String[] { + "cp1383", // JDK historical + "ibm1383", + "ibm-1383", + "1383" + } ), + + Arguments.of("x-IBM970" , + new String[] { + "cp970", // JDK historical + "ibm970", + "ibm-970", + "ibm-eucKR", + "970" + } ), + + Arguments.of("x-IBM964" , + new String[] { + "cp964", // JDK historical + "ibm964", + "ibm-964", + "964" + } ), + + Arguments.of("x-IBM33722" , + new String[] { + "cp33722", // JDK historical + "ibm33722", + "ibm-33722", + "ibm-5050", // from IBM alias list + "ibm-33722_vascii_vpua", // from IBM alias list + "33722" + } ), + + Arguments.of("IBM01140" , + new String[] { + "cp1140", // JDK historical + "ccsid01140", + "cp01140", + // "ebcdic-us-037+euro" + } ), + + Arguments.of("IBM01141" , + new String[] { + "cp1141", // JDK historical + "ccsid01141", + "cp01141", + // "ebcdic-de-273+euro" + } ), + + Arguments.of("IBM01142" , + new String[] { + "cp1142", // JDK historical + "ccsid01142", + "cp01142", + // "ebcdic-no-277+euro", + // "ebcdic-dk-277+euro" + } ), + + Arguments.of("IBM01143" , + new String[] { + "cp1143", // JDK historical + "ccsid01143", + "cp01143", + // "ebcdic-fi-278+euro", + // "ebcdic-se-278+euro" + } ), + + Arguments.of("IBM01144" , + new String[] { + "cp1144", // JDK historical + "ccsid01144", + "cp01144", + // "ebcdic-it-280+euro" + } ), + + Arguments.of("IBM01145" , + new String[] { + "cp1145", // JDK historical + "ccsid01145", + "cp01145", + // "ebcdic-es-284+euro" + } ), + + Arguments.of("IBM01146" , + new String[] { + "cp1146", // JDK historical + "ccsid01146", + "cp01146", + // "ebcdic-gb-285+euro" + } ), + + Arguments.of("IBM01147" , + new String[] { + "cp1147", // JDK historical + "ccsid01147", + "cp01147", + // "ebcdic-fr-277+euro" + } ), + + Arguments.of("IBM01148" , + new String[] { + "cp1148", // JDK historical + "ccsid01148", + "cp01148", + // "ebcdic-international-500+euro" + } ), + + Arguments.of("IBM01149" , + new String[] { + "cp1149", // JDK historical + "ccsid01149", + "cp01149", + // "ebcdic-s-871+euro" + } ), + + Arguments.of("IBM00858" , + new String[] { + "cp858", // JDK historical + "ccsid00858", + "cp00858", + // "PC-Multilingual-850+euro" + } ), + + Arguments.of("x-MacRoman", + new String[] { + "MacRoman" // JDK historical + }), + + Arguments.of("x-MacCentralEurope", + new String[] { + "MacCentralEurope" // JDK historical + }), + + Arguments.of("x-MacCroatian", + new String[] { + "MacCroatian" // JDK historical + }), + + + Arguments.of("x-MacCroatian", + new String[] { + "MacCroatian" // JDK historical + }), + + + Arguments.of("x-MacGreek", + new String[] { + "MacGreek" // JDK historical + }), + + Arguments.of("x-MacCyrillic", + new String[] { + "MacCyrillic" // JDK historical + }), + + Arguments.of("x-MacUkraine", + new String[] { + "MacUkraine" // JDK historical + }), + + Arguments.of("x-MacTurkish", + new String[] { + "MacTurkish" // JDK historical + }), + + Arguments.of("x-MacArabic", + new String[] { + "MacArabic" // JDK historical + }), + + Arguments.of("x-MacHebrew", + new String[] { + "MacHebrew" // JDK historical + }), + + Arguments.of("x-MacIceland", + new String[] { + "MacIceland" // JDK historical + }), + + Arguments.of("x-MacRomania", + new String[] { + "MacRomania" // JDK historical + }), + + Arguments.of("x-MacThai", + new String[] { + "MacThai" // JDK historical + }), + + Arguments.of("x-MacSymbol", + new String[] { + "MacSymbol" // JDK historical + }), + + Arguments.of("x-MacDingbat", + new String[] { + "MacDingbat" // JDK historical + }) + ); } }