Skip to content

Commit

Permalink
8301119: Support for GB18030-2022
Browse files Browse the repository at this point in the history
Reviewed-by: sgehwolf
Backport-of: a253b4602147633a3d2e83775d1feef4f12a5272
  • Loading branch information
gnu-andrew committed May 26, 2023
1 parent 682728e commit 5c4e744
Show file tree
Hide file tree
Showing 14 changed files with 250 additions and 131 deletions.
12 changes: 6 additions & 6 deletions make/data/charsetmapping/charsets
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2000, 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
Expand Down Expand Up @@ -477,6 +477,11 @@ charset x-IBM874 IBM874
alias ibm-874
alias 874

# alias for GB18030 is generated at runtime
charset GB18030 GB18030
package sun.nio.cs
type source

########################################################
#
# charsets provided by ExtendedCharsets provider.
Expand Down Expand Up @@ -564,11 +569,6 @@ charset GBK GBK # Simplified Chinese
alias windows-936
alias CP936

charset GB18030 GB18030
package sun.nio.cs.ext
type template
alias gb18030-2000

charset GB2312 EUC_CN
package sun.nio.cs.ext
type dbcs
Expand Down
1 change: 0 additions & 1 deletion make/data/charsetmapping/stdcs-aix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Big5_HKSCS
EUC_CN
EUC_KR
GBK
GB18030
IBM856
IBM921
IBM922
Expand Down
1 change: 0 additions & 1 deletion make/data/charsetmapping/stdcs-linux
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ EUC_JP_LINUX
EUC_JP_Open
EUC_TW
GBK
GB18030
ISO_8859_11
ISO_8859_3
ISO_8859_6
Expand Down
1 change: 0 additions & 1 deletion make/data/charsetmapping/stdcs-solaris
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ EUC_JP_LINUX
EUC_JP_Open
EUC_TW
GBK
GB18030
ISO_8859_11
ISO_8859_3
ISO_8859_6
Expand Down
1 change: 0 additions & 1 deletion make/data/charsetmapping/stdcs-windows
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# generate these charsets into sun.nio.cs
#
GBK
GB18030
Johab
MS1255
MS1256
Expand Down
38 changes: 23 additions & 15 deletions make/jdk/src/classes/build/tools/charsetmapping/SPI.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 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
Expand Down Expand Up @@ -50,18 +50,19 @@ public static void genClass(String type,
out.println(line);
} else {
charsets.values()
.stream()
.filter(cs -> cs.pkgName.equals("sun.nio.cs.ext") &&
!cs.isInternal &&
(cs.os == null || cs.os.equals(os)))
.forEach( cs -> {
out.printf(" charset(\"%s\", \"%s\",%n", cs.csName, cs.clzName);
out.printf(" new String[] {%n");
for (String alias : cs.aliases) {
out.printf(" \"%s\",%n", alias);
}
out.printf(" });%n%n");
});
.stream()
.filter(cs -> cs.pkgName.equals("sun.nio.cs.ext") &&
!cs.isInternal &&
(cs.os == null || cs.os.equals(os)))
.forEach( cs -> {
out.printf(" charset(\"%s\", \"%s\",%n", cs.csName, cs.clzName);
out.printf(" new String[] {%n");
for (String alias : cs.aliases) {
out.printf(" \"%s\",%n",
alias);
}
out.printf(" });%n%n");
});
}
}
} else if (type.startsWith("stdcs")) { // StandardCharsets.java
Expand Down Expand Up @@ -93,8 +94,15 @@ public static void genClass(String type,
.filter(cs -> cs.pkgName.equals("sun.nio.cs"))
.forEach( cs -> {
if (cs.aliases == null || cs.aliases.length == 0) {
out.printf(" static String[] aliases_%s() { return null; }%n%n",
cs.clzName);
if (cs.csName.equals("GB18030")) {
out.printf(" static String[] aliases_GB18030() { return new String[] {%n");
out.printf(" GB18030.IS_2000 ? \"gb18030-2000\" : \"gb18030-2022\"%n");
out.printf(" };%n");
out.printf(" }%n%n");
} else {
out.printf(" static String[] aliases_%s() { return null; }%n%n",
cs.clzName);
}
} else {
boolean methodEnd = true;
// non-final for SJIS and MS932 to support sun.nio.cs.map
Expand Down

1 comment on commit 5c4e744

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.