Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8310947

gb18030-2000 not selectable with LANG=zh_CN.GB18030 after JDK-8301119

XMLWordPrintable

        JDK-8301119 introduced GB18030-2022 support. As a fallback, a property jdk.charset.GB18030 has been introduced to select the older 2000 standard. However, that no longer seems to be selectable with the Chinese locale and using the GB18030 encoding (which now defaults to 'gb18030-2022`).

        This test:
        $ cat Test.java
        import java.nio.charset.Charset;
        public class Test {
        public static void main(String[] args) {
        Charset.forName("GB18030");
        if ("2000".equals(System.getProperty("jdk.charset.GB18030"))) {
        Charset.forName("gb18030-2000");
        } else {
        Charset.forName("gb18030-2022");
        }
        }
        }

        Fails when run as such:

        $ LANG=zh_CN.GB18030 ./build/linux-x86_64-server-release/images/jdk/bin/java -Djdk.charset.GB18030=2000 Test
        Exception in thread "main" java.nio.charset.UnsupportedCharsetException: gb18030-2000
        at java.base/java.nio.charset.Charset.forName(Charset.java:543)
        at Test.main(Test.java:6)
        $ echo $?
        1

              naoto Naoto Sato
              sgehwolf Severin Gehwolf
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: