--- old/make/gensrc/Gensrc-jdk.charsets.gmk 2015-02-16 10:40:49.000000000 -0800 +++ new/make/gensrc/Gensrc-jdk.charsets.gmk 2015-02-16 10:40:48.000000000 -0800 @@ -30,23 +30,26 @@ # Generate files using the charsetmapping tool # CHARSET_DATA_DIR := $(JDK_TOPDIR)/make/data/charsetmapping + CHARSET_GENSRC_JAVA_DIR_CS := $(SUPPORT_OUTPUTDIR)/gensrc/jdk.charsets/sun/nio/cs/ext CHARSET_DONE_CS := $(CHARSET_GENSRC_JAVA_DIR_CS)/_the.charsetmapping CHARSET_COPYRIGHT_HEADER := $(JDK_TOPDIR)/make/src/classes/build/tools/charsetmapping CHARSET_TEMPLATES := \ $(CHARSET_DATA_DIR)/SingleByte-X.java.template \ $(CHARSET_DATA_DIR)/DoubleByte-X.java.template +CHARSET_EXTENDED_JAVA_TEMPLATES := \ + $(JDK_TOPDIR)/src/jdk.charsets/share/classes/sun/nio/cs/ext/ExtendedCharsets.java.template +CHARSET_EXTENDED_JAVA_DIR := $(JDK_TOPDIR)/src/jdk.charsets/share/classes/sun/nio/cs/ext +CHARSET_EXTENDED := extcs +CHARSET_STANDARD_OS := stdcs-$(OPENJDK_TARGET_OS) -$(CHARSET_DONE_CS)-extsbcs: $(CHARSET_DATA_DIR)/extsbcs \ - $(CHARSET_TEMPLATES) $(BUILD_TOOLS_JDK) - $(MKDIR) -p $(@D) - $(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR_CS) extsbcs - $(TOUCH) '$@' - -$(CHARSET_DONE_CS)-dbcs: $(CHARSET_DATA_DIR)/dbcs \ - $(CHARSET_TEMPLATES) $(BUILD_TOOLS_JDK) +$(CHARSET_DONE_CS)-extcs: $(CHARSET_DATA_DIR)/charsets \ + $(CHARSET_TEMPLATES) $(CHARSET_EXTENDED_DATA) $(BUILD_TOOLS_JDK) $(MKDIR) -p $(@D) - $(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR_CS) dbcs + $(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR_CS) \ + extcs charsets $(CHARSET_STANDARD_OS) \ + $(CHARSET_EXTENDED_JAVA_TEMPLATES) \ + $(CHARSET_EXTENDED_JAVA_DIR) $(TOUCH) '$@' $(CHARSET_DONE_CS)-hkscs: $(CHARSET_COPYRIGHT_HEADER)/HKSCS.java \ @@ -67,8 +70,7 @@ $(TOOL_CHARSETMAPPING) '$<' '$@' sjis0213 GENSRC_JDK_CHARSETS += \ - $(CHARSET_DONE_CS)-extsbcs \ - $(CHARSET_DONE_CS)-dbcs \ + $(CHARSET_DONE_CS)-extcs \ $(CHARSET_DONE_CS)-hkscs \ $(CHARSET_DONE_CS)-euctw \ $(CHARSET_GENSRC_JAVA_DIR_CS)/sjis0213.dat \ --- old/make/gensrc/GensrcCharsetMapping.gmk 2015-02-16 10:40:50.000000000 -0800 +++ new/make/gensrc/GensrcCharsetMapping.gmk 2015-02-16 10:40:50.000000000 -0800 @@ -25,112 +25,27 @@ ################################################################################ # -# Generate files using the charsetmapping tool +# Generate StandardCharsets.java and individul sun.nio.cs charset class using +# the charsetmapping tool # CHARSET_DATA_DIR := $(JDK_TOPDIR)/make/data/charsetmapping +CHARSET_EXTSRC_DIR := $(JDK_TOPDIR)/src/jdk.charsets/share/classes/sun/nio/cs/ext CHARSET_GENSRC_JAVA_DIR_BASE := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/nio/cs CHARSET_DONE_BASE := $(CHARSET_GENSRC_JAVA_DIR_BASE)/_the.charsetmapping CHARSET_TEMPLATES := \ $(CHARSET_DATA_DIR)/SingleByte-X.java.template \ $(CHARSET_DATA_DIR)/DoubleByte-X.java.template +CHARSET_STANDARD_JAVA_TEMPLATES := \ + $(JDK_TOPDIR)/src/java.base/share/classes/sun/nio/cs/StandardCharsets.java.template +CHARSET_STANDARD_OS := stdcs-$(OPENJDK_TARGET_OS) -$(CHARSET_DONE_BASE)-sbcs: $(CHARSET_DATA_DIR)/sbcs \ +$(CHARSET_DONE_BASE)-stdcs: $(CHARSET_DATA_DIR)/charsets \ $(CHARSET_TEMPLATES) $(BUILD_TOOLS_JDK) $(MKDIR) -p $(@D) - $(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR_BASE) sbcs + $(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR_BASE) \ + stdcs charsets $(CHARSET_STANDARD_OS) \ + $(CHARSET_STANDARD_JAVA_TEMPLATES) $(CHARSET_EXTSRC_DIR) \ $(TOUCH) '$@' -GENSRC_JAVA_BASE += $(CHARSET_DONE_BASE)-sbcs +GENSRC_JAVA_BASE += $(CHARSET_DONE_BASE)-stdcs -################################################################################ -# -# Generate the sun/nio/cs/StandardCharsets.java file -# -CHARSET_STANDARD_GENSRC_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/_standardcharsets -CHARSET_STANDARD_DATA := $(CHARSET_DATA_DIR)/standard-charsets -CHARSET_STANDARD_JAVA := sun/nio/cs/StandardCharsets.java - -CHARSET_ALIASES_TABLES_AWK := ' \ - BEGIN { n = 1; m = 1; } \ - /^[ \t]*charset / { \ - csn = $$2; cln = $$3; \ - lcsn = tolower(csn); \ - lcsns[n++] = lcsn; \ - csns[lcsn] = csn; \ - classMap[lcsn] = cln; \ - if (n > 2) \ - printf " };\n\n"; \ - printf " static final String[] aliases_%s = new String[] {\n", cln; \ - } \ - /^[ \t]*alias / { \ - acsns[m++] = tolower($$2); \ - aliasMap[tolower($$2)] = lcsn; \ - printf " \"%s\",\n", $$2; \ - } \ - END { \ - printf " };\n\n"; \ - } ' - -CHARSET_ALIASES_MAP_AWK := ' \ - /^[ \t]*charset / { \ - csn = $$2; \ - lcsn = tolower(csn); \ - } \ - /^[ \t]*alias / { \ - an = tolower($$2); \ - printf "%-20s \"%s\"\n", an, lcsn; \ - } ' - -CHARSET_CLASSES_MAP_AWK := ' \ - /^[ \t]*charset / { \ - csn = $$2; cln = $$3; \ - lcsn = tolower(csn); \ - printf "%-20s \"%s\"\n", lcsn, cln; \ - } ' - -# This target should be referenced using the order-only operator (|) -$(CHARSET_STANDARD_GENSRC_DIR): - $(MKDIR) -p '$@' - -$(CHARSET_STANDARD_GENSRC_DIR)/aliases-tables.java.snippet: $(CHARSET_STANDARD_DATA) \ - | $(CHARSET_STANDARD_GENSRC_DIR) - $(NAWK) < '$<' > '$@' $(CHARSET_ALIASES_TABLES_AWK) - -$(CHARSET_STANDARD_GENSRC_DIR)/aliases-map: $(CHARSET_STANDARD_DATA) \ - | $(CHARSET_STANDARD_GENSRC_DIR) - $(NAWK) < '$<' > '$@' $(CHARSET_ALIASES_MAP_AWK) - -$(CHARSET_STANDARD_GENSRC_DIR)/classes-map: $(CHARSET_STANDARD_DATA) \ - | $(CHARSET_STANDARD_GENSRC_DIR) - $(NAWK) < '$<' > '$@' $(CHARSET_CLASSES_MAP_AWK) - -$(CHARSET_STANDARD_GENSRC_DIR)/aliases-map.java.snippet: $(CHARSET_STANDARD_GENSRC_DIR)/aliases-map \ - $(BUILD_TOOLS_JDK) | $(CHARSET_STANDARD_GENSRC_DIR) - $(TOOL_HASHER) -i Aliases < '$<' > '$@' - -$(CHARSET_STANDARD_GENSRC_DIR)/classes-map.java.snippet: $(CHARSET_STANDARD_GENSRC_DIR)/classes-map \ - $(BUILD_TOOLS_JDK) | $(CHARSET_STANDARD_GENSRC_DIR) - $(TOOL_HASHER) -i Classes < '$<' > '$@' - -$(CHARSET_STANDARD_GENSRC_DIR)/cache-map.java.snippet: $(CHARSET_STANDARD_GENSRC_DIR)/classes-map \ - $(BUILD_TOOLS_JDK) | $(CHARSET_STANDARD_GENSRC_DIR) - $(TOOL_HASHER) -i -e Cache -t Charset < '$<' > '$@' - -$(eval $(call SetupTextFileProcessing, BUILD_CHARSET_STANDARD, \ - SOURCE_FILES := $(JDK_TOPDIR)/src/java.base/share/classes/$(CHARSET_STANDARD_JAVA).template, \ - OUTPUT_FILE := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/$(CHARSET_STANDARD_JAVA), \ - INCLUDES := \ - _INCLUDE_ALIASES_TABLES_ => $(CHARSET_STANDARD_GENSRC_DIR)/aliases-tables.java.snippet ; \ - _INCLUDE_ALIASES_MAP_ => $(CHARSET_STANDARD_GENSRC_DIR)/aliases-map.java.snippet ; \ - _INCLUDE_CLASSES_MAP_ => $(CHARSET_STANDARD_GENSRC_DIR)/classes-map.java.snippet ; \ - _INCLUDE_CACHE_MAP_ => $(CHARSET_STANDARD_GENSRC_DIR)/cache-map.java.snippet ; , \ -)) - -# Processing of template depends on the snippets being generated first -$(BUILD_CHARSET_STANDARD): \ - $(CHARSET_STANDARD_GENSRC_DIR)/aliases-tables.java.snippet \ - $(CHARSET_STANDARD_GENSRC_DIR)/aliases-map.java.snippet \ - $(CHARSET_STANDARD_GENSRC_DIR)/classes-map.java.snippet \ - $(CHARSET_STANDARD_GENSRC_DIR)/cache-map.java.snippet - -GENSRC_JAVA_BASE += $(BUILD_CHARSET_STANDARD) --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/make/data/charsetmapping/charsets 2015-02-16 10:40:51.000000000 -0800 @@ -0,0 +1,1818 @@ +# +# Copyright (c) 2000, 2015, 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. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# + +######################################################## +# +# Standard charsets provided by StandardCharsets provider. +# +# Note that these "standard" charsets listed here are not +# necessary to be the "Standard charsets" defined in the +# specification of java.nio.charset.Charset. Instead these +# are the charsets that this implementation believes should +# be packaged into the charsets provider class "StandardCharsets" +# which is initialized at startup time by java.nio.charset.Charset, +# compared to the charsets packaged in "ExtendedCharsets" provider, +# which is lazy initialized. +######################################################## + +charset US-ASCII US_ASCII + package sun.nio.cs + type source + alias iso-ir-6 # IANA aliases + alias ANSI_X3.4-1986 + alias ISO_646.irv:1991 + alias ASCII + alias ISO646-US + alias us + alias IBM367 + alias cp367 + alias csASCII + alias default + # Other aliases + alias 646 # Solaris POSIX locale + alias iso_646.irv:1983 + alias ANSI_X3.4-1968 # Linux POSIX locale (RedHat) + alias ascii7 + +charset UTF-8 UTF_8 + package sun.nio.cs + type source + alias UTF8 # JDK historical + alias unicode-1-1-utf-8 + +charset CESU-8 CESU_8 + package sun.nio.cs + type source + alias CESU8 + alias csCESU-8 + +charset UTF-16 UTF_16 + package sun.nio.cs + type source + alias UTF_16 # JDK historical + alias utf16 + alias unicode + alias UnicodeBig + +charset UTF-16BE UTF_16BE + package sun.nio.cs + type source + alias UTF_16BE + alias ISO-10646-UCS-2 + alias X-UTF-16BE + alias UnicodeBigUnmarked + +charset UTF-16LE UTF_16LE + package sun.nio.cs + type source + alias UTF_16LE + alias X-UTF-16LE + alias UnicodeLittleUnmarked + +charset x-UTF-16LE-BOM UTF_16LE_BOM + package sun.nio.cs + type source + alias UnicodeLittle + +charset UTF-32 UTF_32 + package sun.nio.cs + type source + alias UTF_32 + alias UTF32 + +charset UTF-32LE UTF_32LE + package sun.nio.cs + type source + alias UTF_32LE + alias X-UTF-32LE + +charset UTF-32BE UTF_32BE + package sun.nio.cs + type source + alias UTF_32BE + alias X-UTF-32BE + +charset X-UTF-32LE-BOM UTF_32LE_BOM + package sun.nio.cs + type source + alias UTF_32LE_BOM + alias UTF-32LE-BOM + +charset X-UTF-32BE-BOM UTF_32BE_BOM + package sun.nio.cs + type source + alias UTF_32BE_BOM + alias UTF-32BE-BOM + +charset ISO-8859-1 ISO_8859_1 + package sun.nio.cs + type source + alias iso-ir-100 # IANA aliases + alias ISO_8859-1 + alias latin1 + alias l1 + alias IBM819 + alias cp819 + alias csISOLatin1 + alias 819 # Other aliases + alias IBM-819 + alias ISO8859_1 + alias ISO_8859-1:1987 + alias ISO_8859_1 + alias 8859_1 + alias ISO8859-1 + +charset ISO-8859-2 ISO_8859_2 + package sun.nio.cs + type sbcs + hisname ISO8859_2 + ascii true + alias iso8859_2 # JDK historical + alias 8859_2 + alias iso-ir-101 + alias ISO_8859-2 + alias ISO_8859-2:1987 + alias ISO8859-2 + alias latin2 + alias l2 + alias ibm912 + alias ibm-912 + alias cp912 + alias 912 + alias csISOLatin2 + +charset ISO-8859-4 ISO_8859_4 + package sun.nio.cs + type sbcs + hisname ISO8859_4 + ascii true + alias iso8859_4 # JDK historical + alias iso8859-4 + alias 8859_4 + alias iso-ir-110 + alias ISO_8859-4 + alias ISO_8859-4:1988 + alias latin4 + alias l4 + alias ibm914 + alias ibm-914 + alias cp914 + alias 914 + alias csISOLatin4 + +charset ISO-8859-5 ISO_8859_5 + package sun.nio.cs + type sbcs + hisname ISO8859_5 + ascii true + alias iso8859_5 # JDK historical + alias 8859_5 + alias iso-ir-144 + alias ISO_8859-5 + alias ISO_8859-5:1988 + alias ISO8859-5 + alias cyrillic + alias ibm915 + alias ibm-915 + alias cp915 + alias 915 + alias csISOLatinCyrillic + +charset ISO-8859-7 ISO_8859_7 + package sun.nio.cs + type sbcs + hisname ISO8859_7 + ascii true + alias iso8859_7 # JDK historical + alias 8859_7 + alias iso-ir-126 + alias ISO_8859-7 + alias ISO_8859-7:1987 + alias ELOT_928 + alias ECMA-118 + alias greek + alias greek8 + alias csISOLatinGreek + alias sun_eu_greek # Solaris 7/8 compatibility + alias ibm813 + alias ibm-813 + alias 813 + alias cp813 + alias iso8859-7 # Solaris 9 compatibility + +charset ISO-8859-9 ISO_8859_9 + package sun.nio.cs + type sbcs + hisname ISO8859_9 + ascii true + alias iso8859_9 # JDK historical + alias 8859_9 + alias iso-ir-148 + alias ISO_8859-9 + alias ISO_8859-9:1989 + alias ISO8859-9 + alias latin5 + alias l5 + alias ibm920 + alias ibm-920 + alias 920 + alias cp920 + alias csISOLatin5 + +charset ISO-8859-13 ISO_8859_13 + package sun.nio.cs + type sbcs + hisname ISO8859_13 + ascii true + alias iso8859_13 # JDK historical + alias 8859_13 + alias iso_8859-13 + alias ISO8859-13 + +charset ISO-8859-15 ISO_8859_15 + package sun.nio.cs + type sbcs + hisname ISO8859_15 + ascii true + alias ISO_8859-15 # IANA alias + alias 8859_15 # Other aliases + alias ISO-8859-15 + alias ISO8859_15 + alias ISO8859-15 + alias IBM923 + alias IBM-923 + alias cp923 + alias 923 + alias LATIN0 + alias LATIN9 + alias L9 + alias csISOlatin0 + alias csISOlatin9 + alias ISO8859_15_FDIS + +charset KOI8-R KOI8_R + package sun.nio.cs + type sbcs + hisname KOI8_R + ascii true + alias koi8_r # JDK historical + alias koi8 + alias cskoi8r + +charset KOI8-U KOI8_U + package sun.nio.cs + type sbcs + hisname KOI8_U + ascii true + alias koi8_u + +charset windows-1250 MS1250 + package sun.nio.cs + type sbcs + hisname Cp1250 + ascii true + alias cp1250 # JDK historical + alias cp5346 # Euro IBM CCSID + +charset windows-1251 MS1251 + package sun.nio.cs + type sbcs + hisname Cp1251 + ascii true + alias cp1251 # JDK historical + alias cp5347 # Euro IBM CCSID + alias ansi-1251 # Solaris compatibility + +charset windows-1252 MS1252 + package sun.nio.cs + type sbcs + hisname Cp1252 + ascii true + alias cp1252 # JDK historical + alias cp5348 # Euro IBM CCSID + +charset windows-1253 MS1253 + package sun.nio.cs + type sbcs + hisname Cp1253 + ascii true + alias cp1253 # JDK historical + alias cp5349 # Euro IBM CCSID + +charset windows-1254 MS1254 + package sun.nio.cs + type sbcs + hisname Cp1254 + ascii true + alias cp1254 # JDK historical + alias cp5350 # Euro IBM CCSID + +charset windows-1257 MS1257 + package sun.nio.cs + type sbcs + hisname Cp1257 + ascii true + alias cp1257 # JDK historical + alias cp5353 # Euro IBM CCSID + + +charset IBM437 IBM437 + package sun.nio.cs + type sbcs + hisname Cp437 + ascii false + alias cp437 #JDK historical + alias ibm437 + alias ibm-437 + alias 437 + alias cspc8codepage437 + alias windows-437 + +charset x-IBM737 IBM737 + package sun.nio.cs + type sbcs + hisname Cp737 + ascii false + alias cp737 #JDK historical + alias ibm737 + alias ibm-737 + alias 737 + +charset IBM775 IBM775 + package sun.nio.cs + type sbcs + hisname Cp775 + ascii false + alias cp775 #JDK historical + alias ibm775 + alias ibm-775 + alias 775 + +charset IBM850 IBM850 + package sun.nio.cs + type sbcs + hisname Cp850 + ascii false + alias cp850 #JDK historical + alias ibm-850 + alias ibm850 + alias 850 + alias cspc850multilingual + +charset IBM852 IBM852 + package sun.nio.cs + type sbcs + hisname Cp852 + ascii false + alias cp852 #JDK historical + alias ibm852 + alias ibm-852 + alias 852 + alias csPCp852 + +charset IBM855 IBM855 + package sun.nio.cs + type sbcs + hisname Cp855 + ascii false + alias cp855 #JDK historical + alias ibm-855 + alias ibm855 + alias 855 + alias cspcp855 + +charset IBM857 IBM857 + package sun.nio.cs + type sbcs + hisname Cp857 + ascii false + alias cp857 #JDK historical + alias ibm857 + alias ibm-857 + alias 857 + alias csIBM857 + +charset IBM00858 IBM858 + package sun.nio.cs + type sbcs + hisname Cp858 + ascii false + alias cp858 #JDK historical + alias ccsid00858 + alias cp00858 + alias 858 + alias PC-Multilingual-850+euro + +charset IBM862 IBM862 + package sun.nio.cs + type sbcs + hisname Cp862 + ascii false + alias cp862 #JDK historical + alias ibm862 + alias ibm-862 + alias 862 + alias csIBM862 + alias cspc862latinhebrew + +charset IBM866 IBM866 + package sun.nio.cs + type sbcs + hisname Cp866 + ascii false + alias cp866 #JDK historical + alias ibm866 + alias ibm-866 + alias 866 + alias csIBM866 + +charset x-IBM874 IBM874 + package sun.nio.cs + type sbcs + hisname Cp874 + ascii false + alias cp874 #JDK historical + alias ibm874 + alias ibm-874 + alias 874 + +######################################################## +# +# charsets provided by ExtendedCharsets provider. +# +######################################################## +charset Big5 Big5 + package sun.nio.cs.ext + type dbcs + hisname Big5 + ascii true + minmax 0xa1 0xf9 0x40 0xfe + alias csBig5 # IANA aliases + +charset x-MS950-HKSCS-XP MS950_HKSCS_XP + package sun.nio.cs.ext + type template + alias MS950_HKSCS_XP # JDK historical; + +charset x-MS950-HKSCS MS950_HKSCS + package sun.nio.cs.ext + type source + hisname MS950_HKSCS + ascii true + alias MS950_HKSCS # JDK historical; + +charset x-windows-950 MS950 + package sun.nio.cs.ext + type dbcs + hisname MS950 + ascii true + minmax 0x81 0xfe 0x40 0xfe + alias ms950 # JDK historical + alias windows-950 + +charset x-windows-874 MS874 + package sun.nio.cs.ext + type sbcs + hisname MS874 + ascii true + alias ms874 # JDK historical + alias ms-874 + alias windows-874 + +charset x-EUC-TW EUC_TW + package sun.nio.cs.ext + type source + alias euc_tw # JDK historical + alias euctw + alias cns11643 + alias EUC-TW + +charset Big5-HKSCS Big5_HKSCS + package sun.nio.cs.ext + type template + hisname Big5_HKSCS + ascii true + alias Big5_HKSCS # JDK historical + alias big5hk + alias big5-hkscs + alias big5hkscs # Linux alias + +charset x-Big5-HKSCS-2001 Big5_HKSCS_2001 + package sun.nio.cs.ext + type source + alias Big5_HKSCS_2001 + alias big5hk-2001 + alias big5-hkscs-2001 + alias big5-hkscs:unicode3.0 + alias big5hkscs-2001 + +charset x-Big5-Solaris Big5_Solaris + package sun.nio.cs.ext + type template + hisname Big5_Solaris + ascii true + alias Big5_Solaris # JDK historical + + +charset GBK GBK # Simplified Chinese + package sun.nio.cs.ext + type dbcs + hisname GBK + ascii true + minmax 0x81 0xfe 0x40 0xfe + alias windows-936 + alias CP936 + +charset GB18030 GB18030 + package sun.nio.cs.ext + type source + alias gb18030-2000 + +charset GB2312 EUC_CN + package sun.nio.cs.ext + type dbcs + hisname EUC_CN + ascii true + minmax 0xa1 0xf7 0xa1 0xfe + # IANA aliases + alias gb2312 + alias gb2312-80 + alias gb2312-1980 + alias euc-cn + alias euccn + alias x-EUC-CN # 1.4 compatibility + alias EUC_CN # JDK historical + +charset x-mswin-936 MS936 + package sun.nio.cs.ext + type dbcs + hisname MS936 + ascii true + minmax 0x81 0xfe 0x40 0xfe + alias ms936 # JDK historical + alias ms_936 // IANA aliases + +# The definition of this charset may be overridden by the init method, +# below, if the sun.nio.cs.map property is defined. +# +charset Shift_JIS SJIS + package sun.nio.cs.ext + type dbcs + hisname SJIS + ascii true + minmax 0x81 0xfc 0x40 0xfc + # IANA aliases + alias sjis # historical + alias shift_jis + alias shift-jis + alias ms_kanji + alias x-sjis + alias csShiftJIS + +# The definition of this charset may be overridden by the init method, +# below, if the sun.nio.cs.map property is defined. +charset windows-31j MS932 + package sun.nio.cs.ext + type dbcs + hisname MS932 + ascii true + minmax 0x81 0xfc 0x40 0xfc + alias MS932 # JDK historical + alias windows-932 + alias csWindows31J + +charset JIS_X0201 JIS_X_0201 + package sun.nio.cs.ext + type sbcs + hisname JIS_X0201 + ascii true + alias JIS0201 # JDK historical + # IANA aliases + alias JIS_X0201 + alias X0201 + alias csHalfWidthKatakana + +charset x-JIS0208 JIS_X_0208 + package sun.nio.cs.ext + type dbcsonly + hisname JIS0208 + ascii false + minmax 0x21 0x7e 0x21 0x7e + alias JIS0208 # JDK historical + # IANA aliases + alias JIS_C6226-1983 + alias iso-ir-87 + alias x0208 + alias JIS_X0208-1983 + alias csISO87JISX0208 + +charset JIS_X0212-1990 JIS_X_0212 + package sun.nio.cs.ext + type dbcsonly + hisname JIS0212 + ascii false + minmax 0x21 0x7e 0x21 0x7e + alias JIS0212 # JDK historical + # IANA aliases + alias jis_x0212-1990 + alias x0212 + alias iso-ir-159 + alias csISO159JISX02121990 + +charset x-SJIS_0213 SJIS_0213 + package sun.nio.cs.ext + type source + alias sjis-0213 + alias sjis_0213 + alias sjis:2004 + alias sjis_0213:2004 + alias shift_jis_0213:2004 + alias shift_jis:2004 + +charset x-MS932_0213 MS932_0213 + package sun.nio.cs.ext + type source + alias MS932-0213 + alias MS932_0213 + alias MS932:2004 + alias windows-932-0213 + alias windows-932:2004 + +charset EUC-JP EUC_JP + package sun.nio.cs.ext + type template + hisname EUC_JP + ascii true + alias euc_jp # JDK historical + alias eucjis # IANA aliases + alias eucjp + alias Extended_UNIX_Code_Packed_Format_for_Japanese + alias csEUCPkdFmtjapanese + alias x-euc-jp + alias x-eucjp + +charset x-euc-jp-linux EUC_JP_LINUX + package sun.nio.cs.ext + type template + hisname EUC_JP_LINUX + ascii true + alias euc_jp_linux # JDK historical + alias euc-jp-linux + +charset x-eucjp-open EUC_JP_Open + package sun.nio.cs.ext + type template + hisname EUC_JP_Solari + ascii true + alias EUC_JP_Solaris # JDK historical + alias eucJP-open + +charset x-PCK PCK + package sun.nio.cs.ext + type dbcs + hisname PCK + ascii true + minmax 0x81 0xfc 0x40 0xfc + # IANA aliases + alias pck # JDK historical + +charset ISO-2022-JP ISO2022_JP + package sun.nio.cs.ext + type source + # IANA aliases + alias iso2022jp # JDK historical + alias jis + alias csISO2022JP + alias jis_encoding + alias csjisencoding + +charset ISO-2022-JP-2 ISO2022_JP_2 + package sun.nio.cs.ext + type source + # IANA aliases + alias csISO2022JP2 + alias iso2022jp2 + +charset x-windows-50221 MS50221 + package sun.nio.cs.ext + type source + alias ms50221 # JDK historical + alias cp50221 + +charset x-windows-50220 MS50220 + package sun.nio.cs.ext + type source + alias ms50220 # JDK historical + alias cp50220 + +charset x-windows-iso2022jp MSISO2022JP + package sun.nio.cs.ext + type source + alias windows-iso2022jp # JDK historical + +charset x-JISAutoDetect JISAutoDetect + package sun.nio.cs.ext + type source + alias JISAutoDetect # JDK historical + + +charset EUC-KR EUC_KR # Korean + package sun.nio.cs.ext + type dbcs + hisname EUC_KR + ascii true + minmax 0xa1 0xfd 0xa1 0xfe + alias euc_kr # JDK historical + # IANA aliases + alias ksc5601 + alias euckr + alias ks_c_5601-1987 + alias ksc5601-1987 + alias ksc5601_1987 + alias ksc_5601 + alias csEUCKR + alias 5601 + +charset x-windows-949 MS949 + package sun.nio.cs.ext + type dbcs + hisname MS949 + ascii true + minmax 0x81 0xfe 0x41 0xfe + alias ms949 # JDK historical + alias windows949 + alias windows-949 + alias ms_949 # IANA aliases + +charset x-Johab Johab + package sun.nio.cs.ext + type dbcs + hisname x-Johab + ascii true + minmax 0x84 0xf9 0x31 0xfe + alias ksc5601-1992 + alias ksc5601_1992 + alias ms1361 + alias johab # JDK historical + +charset ISO-2022-KR ISO2022_KR + package sun.nio.cs.ext + type source + alias ISO2022KR # JDK historical + alias csISO2022KR + +charset ISO-2022-CN ISO2022_CN + package sun.nio.cs.ext + type source + alias ISO2022CN # JDK historical + alias csISO2022CN + +charset x-ISO-2022-CN-CNS ISO2022_CN_CNS + package sun.nio.cs.ext + type source + alias ISO2022CN_CNS # JDK historical + alias ISO-2022-CN-CNS + +charset x-ISO-2022-CN-GB ISO2022_CN_GB + package sun.nio.cs.ext + type source + alias ISO2022CN_GB # JDK historical + alias ISO-2022-CN-GB + +charset x-ISCII91 ISCII91 + package sun.nio.cs.ext + type source + alias iscii + alias ST_SEV_358-88 + alias iso-ir-153 + alias csISO153GOST1976874 + alias ISCII91 # JDK historical + +charset ISO-8859-3 ISO_8859_3 + package sun.nio.cs.ext + type sbcs + hisname ISO8859_3 + ascii true + alias iso8859_3 # JDK historical + alias 8859_3 + alias ISO_8859-3:1988 + alias iso-ir-109 + alias ISO_8859-3 + alias ISO8859-3 + alias latin3 + alias l3 + alias ibm913 + alias ibm-913 + alias cp913 + alias 913 + alias csISOLatin3 + +charset ISO-8859-6 ISO_8859_6 + package sun.nio.cs.ext + type sbcs + hisname ISO8859_6 + ascii true + alias iso8859_6 # JDK historical + alias 8859_6 + alias iso-ir-127 + alias ISO_8859-6 + alias ISO_8859-6:1987 + alias ISO8859-6 + alias ECMA-114 + alias ASMO-708 + alias arabic + alias ibm1089 + alias ibm-1089 + alias cp1089 + alias 1089 + alias csISOLatinArabic + +charset ISO-8859-8 ISO_8859_8 + package sun.nio.cs.ext + type sbcs + hisname ISO8859_8 + ascii true + alias iso8859_8 # JDK historical + alias 8859_8 + alias iso-ir-138 + alias ISO_8859-8 + alias ISO_8859-8:1988 + alias ISO8859-8 + alias cp916 + alias 916 + alias ibm916 + alias ibm-916 + alias hebrew + alias csISOLatinHebrew + +charset x-iso-8859-11 ISO_8859_11 + package sun.nio.cs.ext + type sbcs + hisname x-iso-8859-11 + ascii true + alias iso-8859-11 + alias iso8859_11 + +charset TIS-620 TIS_620 + package sun.nio.cs.ext + type sbcs + hisname TIS620 + ascii true + alias tis620 # JDK historical + alias tis620.2533 + +# Microsoft Windows codepages + +charset windows-1255 MS1255 + package sun.nio.cs.ext + type sbcs + hisname Cp1255 + ascii true + alias cp1255 # JDK historical + +charset windows-1256 MS1256 + package sun.nio.cs.ext + type sbcs + hisname Cp1256 + ascii true + alias cp1256 # JDK historical + +charset windows-1258 MS1258 + package sun.nio.cs.ext + type sbcs + hisname Cp1258 + ascii true + alias cp1258 # JDK historical + +charset x-IBM942 IBM942 # IBM & PC/MSDOS encodings + package sun.nio.cs.ext + type dbcs + hisname Cp942 + ascii false + minmax 0x81 0xfc 0x40 0xfc + alias cp942 # JDK historical + alias ibm942 + alias ibm-942 + alias 942 + +charset x-IBM942C IBM942C + package sun.nio.cs.ext + type source + alias cp942C # JDK historical + alias ibm942C + alias ibm-942C + alias 942C + +charset x-IBM943 IBM943 + package sun.nio.cs.ext + type dbcs + hisname Cp943 + ascii false + minmax 0x81 0xfc 0x40 0xfc + alias cp943 # JDK historical + alias ibm943 + alias ibm-943 + alias 943 + +charset x-IBM943C IBM943C + package sun.nio.cs.ext + type source + alias cp943C # JDK historical + alias ibm943C + alias ibm-943C + alias 943C + +charset x-IBM948 IBM948 + package sun.nio.cs.ext + type dbcs + hisname Cp948 + ascii true + minmax 0x81 0xfe 0x40 0xfc + alias cp948 # JDK historical + alias ibm948 + alias ibm-948 + alias 948 + +charset x-IBM950 IBM950 + package sun.nio.cs.ext + type dbcs + hisname Cp950 + ascii true + minmax 0x81 0xfe 0x40 0xfe + alias cp950 # JDK historical + alias ibm950 + alias ibm-950 + alias 950 + +charset x-IBM930 IBM930 + package sun.nio.cs.ext + type ebcdic + hisname Cp930 + ascii false + minmax 0x40 0x7f 0x40 0xfe + alias cp930 # JDK historical + alias ibm930 + alias ibm-930 + alias 930 + +charset x-IBM935 IBM935 + package sun.nio.cs.ext + type ebcdic + hisname Cp935 + ascii false + minmax 0x40 0x7f 0x40 0xfe + alias cp935 # JDK historical + alias ibm935 + alias ibm-935 + alias 935 + +charset x-IBM937 IBM937 + package sun.nio.cs.ext + type ebcdic + hisname Cp937 + ascii false + minmax 0x40 0xe2 0x40 0xfe + alias cp937 # JDK historical + alias ibm937 + alias ibm-937 + alias 937 + +charset x-IBM856 IBM856 + package sun.nio.cs.ext + type sbcs + hisname Cp856 + ascii false + alias cp856 # JDK historical + alias ibm-856 + alias ibm856 + alias 856 + +charset IBM860 IBM860 + package sun.nio.cs.ext + type sbcs + hisname Cp860 + ascii false + alias cp860 # JDK historical + alias ibm860 + alias ibm-860 + alias 860 + alias csIBM860 + +charset IBM861 IBM861 + package sun.nio.cs.ext + type sbcs + hisname Cp861 + ascii false + alias cp861 # JDK historical + alias ibm861 + alias ibm-861 + alias 861 + alias csIBM861 + alias cp-is + +charset IBM863 IBM863 + package sun.nio.cs.ext + type sbcs + hisname Cp863 + ascii false + alias cp863 # JDK historical + alias ibm863 + alias ibm-863 + alias 863 + alias csIBM863 + +charset IBM864 IBM864 + package sun.nio.cs.ext + type sbcs + hisname Cp864 + ascii false + alias cp864 # JDK historical + alias ibm864 + alias ibm-864 + alias 864 + alias csIBM864 + + +charset IBM865 IBM865 + package sun.nio.cs.ext + type sbcs + hisname Cp865 + ascii false + alias cp865 # JDK historical + alias ibm865 + alias ibm-865 + alias 865 + alias csIBM865 + +charset IBM868 IBM868 + package sun.nio.cs.ext + type sbcs + hisname Cp868 + ascii false + alias cp868 # JDK historical + alias ibm868 + alias ibm-868 + alias 868 + alias cp-ar + alias csIBM868 + +charset IBM869 IBM869 + package sun.nio.cs.ext + type sbcs + hisname Cp869 + ascii false + alias cp869 # JDK historical + alias ibm869 + alias ibm-869 + alias 869 + alias cp-gr + alias csIBM869 + +charset x-IBM921 IBM921 + package sun.nio.cs.ext + type sbcs + hisname Cp921 + ascii false + alias cp921 # JDK historical + alias ibm921 + alias ibm-921 + alias 921 + +charset x-IBM1006 IBM1006 + package sun.nio.cs.ext + type sbcs + hisname Cp1006 + ascii false + alias cp1006 # JDK historical + alias ibm1006 + alias ibm-1006 + alias 1006 + +charset x-IBM1046 IBM1046 + package sun.nio.cs.ext + type sbcs + hisname Cp1046 + ascii false + alias cp1046 # JDK historical + alias ibm1046 + alias ibm-1046 + alias 1046 + +charset IBM1047 IBM1047 + package sun.nio.cs.ext + type sbcs + hisname Cp1047 + ascii false + alias cp1047 # JDK historical + alias ibm-1047 + alias 1047 + +charset x-IBM1098 IBM1098 + package sun.nio.cs.ext + type sbcs + hisname Cp1098 + ascii false + alias cp1098 # JDK historical + alias ibm1098 + alias ibm-1098 + alias 1098 + +charset IBM037 IBM037 + package sun.nio.cs.ext + type sbcs + hisname Cp037 + ascii false + alias cp037 # JDK historical + alias ibm037 + alias ebcdic-cp-us + alias ebcdic-cp-ca + alias ebcdic-cp-wt + alias ebcdic-cp-nl + alias csIBM037 + alias cs-ebcdic-cp-us + alias cs-ebcdic-cp-ca + alias cs-ebcdic-cp-wt + alias cs-ebcdic-cp-nl + alias ibm-037 + alias ibm-37 + alias cpibm37 + alias 037 + +charset x-IBM1025 IBM1025 + package sun.nio.cs.ext + type sbcs + hisname Cp1025 + ascii false + alias cp1025 # JDK historical + alias ibm1025 + alias ibm-1025 + alias 1025 + +charset IBM1026 IBM1026 + package sun.nio.cs.ext + type sbcs + hisname Cp1026 + ascii false + alias cp1026 # JDK historical + alias ibm1026 + alias ibm-1026 + alias 1026 + +charset x-IBM1112 IBM1112 + package sun.nio.cs.ext + type sbcs + hisname Cp1112 + ascii false + alias cp1112 # JDK historical + alias ibm1112 + alias ibm-1112 + alias 1112 + +charset x-IBM1122 IBM1122 + package sun.nio.cs.ext + type sbcs + hisname Cp1122 + ascii false + alias cp1122 # JDK historical + alias ibm1122 + alias ibm-1122 + alias 1122 + +charset x-IBM1123 IBM1123 + package sun.nio.cs.ext + type sbcs + hisname Cp1123 + ascii false + alias cp1123 # JDK historical + alias ibm1123 + alias ibm-1123 + alias 1123 + +charset x-IBM1124 IBM1124 + package sun.nio.cs.ext + type sbcs + hisname Cp1124 + ascii false + alias cp1124 # JDK historical + alias ibm1124 + alias ibm-1124 + alias 1124 + +charset x-IBM1364 IBM1364 + package sun.nio.cs.ext + type ebcdic + hisname Cp1364 + ascii false + minmax 0x40 0xde 0x40 0xfe + alias cp1364 + alias ibm1364 + alias ibm-1364 + alias 1364 + +charset IBM273 IBM273 + package sun.nio.cs.ext + type sbcs + hisname Cp273 + ascii false + alias cp273 # JDK historical + alias ibm273 + alias ibm-273 + alias 273 + +charset IBM277 IBM277 + package sun.nio.cs.ext + type sbcs + hisname Cp277 + ascii false + alias cp277 # JDK historical + alias ibm277 + alias ibm-277 + alias 277 + +charset IBM278 IBM278 + package sun.nio.cs.ext + type sbcs + hisname Cp278 + ascii false + alias cp278 # JDK historical + alias ibm278 + alias ibm-278 + alias 278 + alias ebcdic-sv + alias ebcdic-cp-se + alias csIBM278 + +charset IBM280 IBM280 + package sun.nio.cs.ext + type sbcs + hisname Cp280 + ascii false + alias cp280 # JDK historical + alias ibm280 + alias ibm-280 + alias 280 + +charset IBM284 IBM284 + package sun.nio.cs.ext + type sbcs + hisname Cp284 + ascii false + alias cp284 # JDK historical + alias ibm284 + alias ibm-284 + alias 284 + alias csIBM284 + alias cpibm284 + +charset IBM285 IBM285 + package sun.nio.cs.ext + type sbcs + hisname Cp285 + ascii false + alias cp285 # JDK historical + alias ibm285 + alias ibm-285 + alias 285 + alias ebcdic-cp-gb + alias ebcdic-gb + alias csIBM285 + alias cpibm285 + +charset IBM297 IBM297 + package sun.nio.cs.ext + type sbcs + hisname Cp297 + ascii false + alias cp297 # JDK historical + alias ibm297 + alias ibm-297 + alias 297 + alias ebcdic-cp-fr + alias cpibm297 + alias csIBM297 + +charset IBM420 IBM420 + package sun.nio.cs.ext + type sbcs + hisname Cp420 + ascii false + alias cp420 # JDK historical + alias ibm420 + alias ibm-420 + alias ebcdic-cp-ar1 + alias 420 + alias csIBM420 + +charset IBM424 IBM424 + package sun.nio.cs.ext + type sbcs + hisname Cp424 + ascii false + alias cp424 # JDK historical + alias ibm424 + alias ibm-424 + alias 424 + alias ebcdic-cp-he + alias csIBM424 + +charset IBM500 IBM500 + package sun.nio.cs.ext + type sbcs + hisname Cp500 + ascii false + alias cp500 # JDK historical + alias ibm500 + alias ibm-500 + alias 500 + alias ebcdic-cp-ch + alias ebcdic-cp-bh + alias csIBM500 + +charset x-IBM833 IBM833 + package sun.nio.cs.ext + type sbcs + hisname Cp833 + ascii false + alias cp833 + alias ibm833 + alias ibm-833 + + +charset x-IBM834 IBM834 # EBCDIC DBCS-only Korean + package sun.nio.cs.ext + type source + alias cp834 + alias ibm834 + alias 834 + alias ibm-834 + +charset IBM-Thai IBM838 + package sun.nio.cs.ext + type sbcs + hisname Cp838 + ascii false + alias cp838 # JDK historical + alias ibm838 + alias ibm-838 + alias 838 + +charset IBM870 IBM870 + package sun.nio.cs.ext + type sbcs + hisname Cp870 + ascii false + alias cp870 # JDK historical + alias ibm870 + alias ibm-870 + alias 870 + alias ebcdic-cp-roece + alias ebcdic-cp-yu + alias csIBM870 + +charset IBM871 IBM871 + package sun.nio.cs.ext + type sbcs + hisname Cp871 + ascii false + alias cp871 # JDK historical + alias ibm871 + alias ibm-871 + alias 871 + alias ebcdic-cp-is + alias csIBM871 + +charset x-IBM875 IBM875 + package sun.nio.cs.ext + type sbcs + hisname Cp875 + ascii false + alias cp875 # JDK historical + alias ibm875 + alias ibm-875 + alias 875 + +charset IBM918 IBM918 + package sun.nio.cs.ext + type sbcs + hisname Cp918 + ascii false + alias cp918 # JDK historical + alias ibm-918 + alias 918 + alias ebcdic-cp-ar2 + +charset x-IBM922 IBM922 + package sun.nio.cs.ext + type sbcs + hisname Cp922 + ascii false + alias cp922 # JDK historical + alias ibm922 + alias ibm-922 + alias 922 + +charset x-IBM1097 IBM1097 + package sun.nio.cs.ext + type sbcs + hisname Cp1097 + ascii false + alias cp1097 # JDK historical + alias ibm1097 + alias ibm-1097 + alias 1097 + +charset x-IBM949 IBM949 + package sun.nio.cs.ext + type dbcs + hisname Cp949 + ascii false + minmax 0x8f 0xfe 0xa1 0xfe + alias cp949 # JDK historical + alias ibm949 + alias ibm-949 + alias 949 + +charset x-IBM949C IBM949C + package sun.nio.cs.ext + type source + alias cp949C # JDK historical + alias ibm949C + alias ibm-949C + alias 949C + +charset x-IBM939 IBM939 + package sun.nio.cs.ext + type ebcdic + hisname Cp939 + ascii false + minmax 0x40 0x7f 0x40 0xfe + alias cp939 # JDK historical + alias ibm939 + alias ibm-939 + alias 939 + +charset x-IBM933 IBM933 + package sun.nio.cs.ext + type ebcdic + hisname Cp933 + ascii false + minmax 0x40 0xdd 0x40 0xfe + alias cp933 # JDK historical + alias ibm933 + alias ibm-933 + alias 933 + +charset x-IBM1381 IBM1381 + package sun.nio.cs.ext + type dbcs + hisname Cp1381 + ascii true + minmax 0x8c 0xf7 0xa1 0xfe + alias cp1381 # JDK historical + alias ibm1381 + alias ibm-1381 + alias 1381 + +charset x-IBM1383 IBM1383 + package sun.nio.cs.ext + type euc_sim + hisname Cp1383 + ascii true + minmax 0xa1 0xfe 0xa1 0xfe + alias cp1383 # JDK historical + alias ibm1383 + alias ibm-1383 + alias 1383 + +charset x-IBM970 IBM970 + package sun.nio.cs.ext + type euc_sim + hisname Cp970 + ascii true + minmax 0xa1 0xfe 0xa1 0xfe + alias cp970 # JDK historical + alias ibm970 + alias ibm-970 + alias ibm-eucKR + alias 970 + +charset x-IBM964 IBM964 + package sun.nio.cs.ext + type source + alias cp964 # JDK historical + alias ibm964 + alias ibm-964 + alias 964 + +charset x-IBM33722 IBM33722 + package sun.nio.cs.ext + type source + alias cp33722 # JDK historical + alias ibm33722 + alias ibm-33722 + alias ibm-5050 # from IBM alias list + alias ibm-33722_vascii_vpua # from IBM alias list + alias 33722 + +charset IBM01140 IBM1140 + package sun.nio.cs.ext + type sbcs + hisname Cp1140 + ascii false + alias cp1140 # JDK historical + alias ccsid01140 + alias cp01140 + alias 1140 + alias ebcdic-us-037+euro + +charset IBM01141 IBM1141 + package sun.nio.cs.ext + type sbcs + hisname Cp1141 + ascii false + alias cp1141 # JDK historical + alias ccsid01141 + alias cp01141 + alias 1141 + alias ebcdic-de-273+euro + +charset IBM01142 IBM1142 + package sun.nio.cs.ext + type sbcs + hisname Cp1142 + ascii false + alias cp1142 # JDK historical + alias ccsid01142 + alias cp01142 + alias 1142 + alias ebcdic-no-277+euro + alias ebcdic-dk-277+euro + +charset IBM01143 IBM1143 + package sun.nio.cs.ext + type sbcs + hisname Cp1143 + ascii false + alias cp1143 # JDK historical + alias ccsid01143 + alias cp01143 + alias 1143 + alias ebcdic-fi-278+euro + alias ebcdic-se-278+euro + +charset IBM01144 IBM1144 + package sun.nio.cs.ext + type sbcs + hisname Cp1144 + ascii false + alias cp1144 # JDK historical + alias ccsid01144 + alias cp01144 + alias 1144 + alias ebcdic-it-280+euro + +charset IBM01145 IBM1145 + package sun.nio.cs.ext + type sbcs + hisname Cp1145 + ascii false + alias cp1145 # JDK historical + alias ccsid01145 + alias cp01145 + alias 1145 + alias ebcdic-es-284+euro + +charset IBM01146 IBM1146 + package sun.nio.cs.ext + type sbcs + hisname Cp1146 + ascii false + alias cp1146 # JDK historical + alias ccsid01146 + alias cp01146 + alias 1146 + alias ebcdic-gb-285+euro + +charset IBM01147 IBM1147 + package sun.nio.cs.ext + type sbcs + hisname Cp1147 + ascii false + alias cp1147 # JDK historical + alias ccsid01147 + alias cp01147 + alias 1147 + alias ebcdic-fr-277+euro + +charset IBM01148 IBM1148 + package sun.nio.cs.ext + type sbcs + hisname Cp1148 + ascii false + alias cp1148 # JDK historical + alias ccsid01148 + alias cp01148 + alias 1148 + alias ebcdic-international-500+euro + +charset IBM01149 IBM1149 + package sun.nio.cs.ext + type sbcs + hisname Cp1149 + ascii false + alias cp1149 # JDK historical + alias ccsid01149 + alias cp01149 + alias 1149 + alias ebcdic-s-871+euro + +charset IBM290 IBM290 + package sun.nio.cs.ext + type sbcs + hisname Cp290 + ascii false + alias cp290 + alias ibm290 + alias ibm-290 + alias csIBM290 + alias EBCDIC-JP-kana + alias 290 + +charset x-IBM300 IBM300 + package sun.nio.cs.ext + type dbcsonly + hisname Cp300 + ascii false + minmax 0x40 0x7f 0x40 0xfe + alias cp300 + alias ibm300 + alias ibm-300 + alias 300 + +# Macintosh MacOS/Apple char encodingd + +charset x-MacRoman MacRoman + package sun.nio.cs.ext + type sbcs + hisname MacRoman + ascii false + alias MacRoman # JDK historical + +charset x-MacCentralEurope MacCentralEurope + package sun.nio.cs.ext + type sbcs + hisname MacCentralEurope + ascii false + alias MacCentralEurope # JDK historical + +charset x-MacCroatian MacCroatian + package sun.nio.cs.ext + type sbcs + hisname MacCroatian + ascii false + alias MacCroatian # JDK historical + +charset x-MacGreek MacGreek + package sun.nio.cs.ext + type sbcs + hisname MacGreek + ascii false + alias MacGreek # JDK historical + +charset x-MacCyrillic MacCyrillic + package sun.nio.cs.ext + type sbcs + hisname MacCyrillic + ascii false + alias MacCyrillic # JDK historical + +charset x-MacUkraine MacUkraine + package sun.nio.cs.ext + type sbcs + hisname MacUkraine + ascii false + alias MacUkraine # JDK historical + +charset x-MacTurkish MacTurkish + package sun.nio.cs.ext + type sbcs + hisname MacTurkish + ascii false + alias MacTurkish # JDK historical + +charset x-MacArabic MacArabic + package sun.nio.cs.ext + type sbcs + hisname MacArabic + ascii false + alias MacArabic # JDK historical + +charset x-MacHebrew MacHebrew + package sun.nio.cs.ext + type sbcs + hisname MacHebrew + ascii false + alias MacHebrew # JDK historical + +charset x-MacIceland MacIceland + package sun.nio.cs.ext + type sbcs + hisname MacIceland + ascii false + alias MacIceland # JDK historical + +charset x-MacRomania MacRomania + package sun.nio.cs.ext + type sbcs + hisname MacRomania + ascii false + alias MacRomania # JDK historical + +charset x-MacThai MacThai + package sun.nio.cs.ext + type sbcs + hisname MacThai + ascii false + alias MacThai # JDK historical + +charset x-MacSymbol MacSymbol + package sun.nio.cs.ext + type sbcs + hisname MacSymbol + ascii false + alias MacSymbol # JDK historical + +charset x-MacDingbat MacDingbat + package sun.nio.cs.ext + type sbcs + hisname MacDingbat + ascii false + alias MacDingbat # JDK historical + +######################################################## +# +# internal use, not to be registered into spi +# +######################################################## + +charset x-JIS0208_Solaris JIS_X_0208_Solaris + package sun.nio.cs.ext + type dbcsonly + hisname JIS0208 + ascii false + minmax 0x21 0x9e 0x21 0x7e + internal true + +charset x-JIS0208_MS5022X JIS_X_0208_MS5022X + package sun.nio.cs.ext + type dbcsonly + hisname JIS_X_0208_MS5022X + ascii false + minmax 0x21 0x7e 0x21 0x7e + internal true + +charset x-JIS0208_MS932 JIS_X_0208_MS932 + package sun.nio.cs.ext + type dbcsonly + hisname JIS_X_0208_MS932 + ascii false + minmax 0x21 0x7e 0x21 0x7e + internal true # "internal implementation + +charset x-JIS0212_Solaris JIS_X_0212_Solaris + package sun.nio.cs.ext + type dbcsonly + hisname JIS_X_0212_Solaris + ascii false + minmax 0x21 0x7e 0x21 0x7e + internal true # "internal implementation + +charset x-JIS0212_MS5022X JIS_X_0212_MS5022X + package sun.nio.cs.ext + type dbcsonly + hisname JIS_X_0212_MS5022X + ascii false + minmax 0x21 0x7e 0x21 0x7e + internal true # "internal implementation --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/make/data/charsetmapping/stdcs-linux 2015-02-16 10:40:52.000000000 -0800 @@ -0,0 +1,19 @@ +# +# generate these charsets into sun.nio.cs +# +Big5 +Big5_Solaris +Big5_HKSCS +EUC_CN +EUC_KR +EUC_JP +EUC_JP_LINUX +EUC_JP_Open +GBK +Johab +PCK +JIS_X_0201 +JIS_X_0208 +JIS_X_0212 +JIS_X_0208_Solaris +JIS_X_0212_Solaris --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/make/data/charsetmapping/stdcs-solaris 2015-02-16 10:40:53.000000000 -0800 @@ -0,0 +1,23 @@ +# +# generate these charsets into sun.nio.cs +# +Big5 +Big5_Solaris +Big5_HKSCS # always together with Big5 +EUC_CN +EUC_KR +EUC_JP +EUC_JP_LINUX +EUC_JP_Open +GBK +ISO_8859_11 +ISO_8859_3 +ISO_8859_6 +ISO_8859_8 +Johab +PCK +JIS_X_0201 +JIS_X_0208 +JIS_X_0212 +JIS_X_0208_Solaris +JIS_X_0212_Solaris --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/make/data/charsetmapping/stdcs-windows 2015-02-16 10:40:54.000000000 -0800 @@ -0,0 +1,16 @@ +# +# generate these charsets into sun.nio.cs +# +GBK +Johab +MS1255 +MS1256 +MS1258 +MS874 +MS932 +JIS_X_0201 # JIS_X_0201 is used by MS932 in its contains() method +SJIS # SJIS must go together with MS932 to support sun.nio.cs.map +MS936 +MS949 +MS950 +MS950_HKSCS_XP --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/make/data/charsetmapping/list_old 2015-02-16 10:40:56.000000000 -0800 @@ -0,0 +1,149 @@ +# +# This is the copy of the old configuration files sbcs, dbcs and extsbcs +# used in jdk8. +############################### sbcs ######################################### +# +# clzName csName hisName containASCII pkg +# +IBM437 IBM437 Cp437 false sun.nio.cs +IBM737 x-IBM737 Cp737 false sun.nio.cs +IBM775 IBM775 Cp775 false sun.nio.cs +IBM850 IBM850 Cp850 false sun.nio.cs +IBM852 IBM852 Cp852 false sun.nio.cs +IBM855 IBM855 Cp855 false sun.nio.cs +IBM857 IBM857 Cp857 false sun.nio.cs +IBM858 IBM00858 Cp858 false sun.nio.cs +IBM862 IBM862 Cp862 false sun.nio.cs +IBM866 IBM866 Cp866 false sun.nio.cs +IBM874 x-IBM874 Cp874 false sun.nio.cs +ISO_8859_2 ISO-8859-2 ISO8859_2 true sun.nio.cs +ISO_8859_4 ISO-8859-4 ISO8859_4 true sun.nio.cs +ISO_8859_5 ISO-8859-5 ISO8859_5 true sun.nio.cs +ISO_8859_7 ISO-8859-7 ISO8859_7 true sun.nio.cs +ISO_8859_9 ISO-8859-9 ISO8859_9 true sun.nio.cs +ISO_8859_13 ISO-8859-13 ISO8859_13 true sun.nio.cs +ISO_8859_15 ISO-8859-15 ISO8859_15 true sun.nio.cs +KOI8_R KOI8-R KOI8_R true sun.nio.cs +KOI8_U KOI8-U KOI8_U true sun.nio.cs +MS1250 windows-1250 Cp1250 true sun.nio.cs +MS1251 windows-1251 Cp1251 true sun.nio.cs +MS1252 windows-1252 Cp1252 true sun.nio.cs +MS1253 windows-1253 Cp1253 true sun.nio.cs +MS1254 windows-1254 Cp1254 true sun.nio.cs +MS1257 windows-1257 Cp1257 true sun.nio.cs +# +############################### extsbcs ####################################### +# +IBM037 IBM037 Cp037 false sun.nio.cs.ext +IBM1006 x-IBM1006 Cp1006 false sun.nio.cs.ext +IBM1025 x-IBM1025 Cp1025 false sun.nio.cs.ext +IBM1026 IBM1026 Cp1026 false sun.nio.cs.ext +IBM1046 x-IBM1046 Cp1046 false sun.nio.cs.ext +IBM1047 IBM1047 Cp1047 false sun.nio.cs.ext +IBM1097 x-IBM1097 Cp1097 false sun.nio.cs.ext +IBM1098 x-IBM1098 Cp1098 false sun.nio.cs.ext +IBM1112 x-IBM1112 Cp1112 false sun.nio.cs.ext +IBM1122 x-IBM1122 Cp1122 false sun.nio.cs.ext +IBM1123 x-IBM1123 Cp1123 false sun.nio.cs.ext +IBM1124 x-IBM1124 Cp1124 false sun.nio.cs.ext +# map tables for 1140-1149 are updated manualy with the u+20ac entry +IBM1140 IBM01140 Cp1140 false sun.nio.cs.ext +IBM1141 IBM01141 Cp1141 false sun.nio.cs.ext +IBM1142 IBM01142 Cp1142 false sun.nio.cs.ext +IBM1143 IBM01143 Cp1143 false sun.nio.cs.ext +IBM1144 IBM01144 Cp1144 false sun.nio.cs.ext +IBM1145 IBM01145 Cp1145 false sun.nio.cs.ext +IBM1146 IBM01146 Cp1146 false sun.nio.cs.ext +IBM1147 IBM01147 Cp1147 false sun.nio.cs.ext +IBM1148 IBM01148 Cp1148 false sun.nio.cs.ext +IBM1149 IBM01149 Cp1149 false sun.nio.cs.ext +IBM273 IBM273 Cp273 false sun.nio.cs.ext +IBM277 IBM277 Cp277 false sun.nio.cs.ext +IBM278 IBM278 Cp278 false sun.nio.cs.ext +IBM280 IBM280 Cp280 false sun.nio.cs.ext +IBM284 IBM284 Cp284 false sun.nio.cs.ext +IBM285 IBM285 Cp285 false sun.nio.cs.ext +IBM290 IBM290 Cp290 false sun.nio.cs.ext +IBM297 IBM297 Cp297 false sun.nio.cs.ext +IBM420 IBM420 Cp420 false sun.nio.cs.ext +IBM424 IBM424 Cp424 false sun.nio.cs.ext +IBM500 IBM500 Cp500 false sun.nio.cs.ext +IBM833 x-IBM833 Cp833 false sun.nio.cs.ext +IBM838 IBM-Thai Cp838 false sun.nio.cs.ext +IBM856 x-IBM856 Cp856 false sun.nio.cs.ext +IBM860 IBM860 Cp860 false sun.nio.cs.ext +IBM861 IBM861 Cp861 false sun.nio.cs.ext +IBM863 IBM863 Cp863 false sun.nio.cs.ext +IBM864 IBM864 Cp864 false sun.nio.cs.ext +IBM865 IBM865 Cp865 false sun.nio.cs.ext +IBM868 IBM868 Cp868 false sun.nio.cs.ext +IBM869 IBM869 Cp869 false sun.nio.cs.ext +IBM870 IBM870 Cp870 false sun.nio.cs.ext +IBM871 IBM871 Cp871 false sun.nio.cs.ext +IBM875 x-IBM875 Cp875 false sun.nio.cs.ext +IBM918 IBM918 Cp918 false sun.nio.cs.ext +IBM921 x-IBM921 Cp921 false sun.nio.cs.ext +IBM922 x-IBM922 Cp922 false sun.nio.cs.ext +# use name as hisname as well, cs did not support hisname prevously +ISO_8859_11 x-iso-8859-11 x-iso-8859-11 true sun.nio.cs.ext +ISO_8859_3 ISO-8859-3 ISO8859_3 true sun.nio.cs.ext +ISO_8859_6 ISO-8859-6 ISO8859_6 true sun.nio.cs.ext +ISO_8859_8 ISO-8859-8 ISO8859_8 true sun.nio.cs.ext +JIS_X_0201 JIS_X0201 JIS_X0201 true sun.nio.cs.ext +MS1255 windows-1255 Cp1255 true sun.nio.cs.ext +MS1256 windows-1256 Cp1256 true sun.nio.cs.ext +MS1258 windows-1258 Cp1258 true sun.nio.cs.ext +MS874 x-windows-874 MS874 true sun.nio.cs.ext +MacArabic x-MacArabic MacArabic false sun.nio.cs.ext +MacCentralEurope x-MacCentralEurope MacCentralEurope false sun.nio.cs.ext +MacCroatian x-MacCroatian MacCroatian false sun.nio.cs.ext +MacCyrillic x-MacCyrillic MacCyrillic false sun.nio.cs.ext +MacDingbat x-MacDingbat MacDingbat false sun.nio.cs.ext +MacGreek x-MacGreek MacGreek false sun.nio.cs.ext +MacHebrew x-MacHebrew MacHebrew false sun.nio.cs.ext +MacIceland x-MacIceland MacIceland false sun.nio.cs.ext +MacRoman x-MacRoman MacRoman false sun.nio.cs.ext +MacRomania x-MacRomania MacRomania false sun.nio.cs.ext +MacSymbol x-MacSymbol MacSymbol false sun.nio.cs.ext +MacThai x-MacThai MacThai false sun.nio.cs.ext +MacTurkish x-MacTurkish MacTurkish false sun.nio.cs.ext +MacUkraine x-MacUkraine MacUkraine false sun.nio.cs.ext +TIS_620 TIS-620 TIS620 true sun.nio.cs.ext +# +############################### dbcs ######################################### +# +#clzName csName hisName dbtype pkg ascii b1min b1max b2min b2max +# +Big5 Big5 Big5 basic sun.nio.cs.ext true 0xa1 0xf9 0x40 0xfe +Johab x-Johab x-Johab basic sun.nio.cs.ext true 0x84 0xf9 0x31 0xfe +EUC_CN GB2312 EUC_CN basic sun.nio.cs.ext true 0xa1 0xf7 0xa1 0xfe +EUC_KR EUC-KR EUC_KR basic sun.nio.cs.ext true 0xa1 0xfd 0xa1 0xfe +MS932 windows-31j MS932 basic sun.nio.cs.ext true 0x81 0xfc 0x40 0xfc +MS936 x-mswin-936 MS936 basic sun.nio.cs.ext true 0x81 0xfe 0x40 0xfe +MS949 x-windows-949 MS949 basic sun.nio.cs.ext true 0x81 0xfe 0x41 0xfe +MS950 x-windows-950 MS950 basic sun.nio.cs.ext true 0x81 0xfe 0x40 0xfe +GBK GBK GBK basic sun.nio.cs.ext true 0x81 0xfe 0x40 0xfe +SJIS Shift_JIS SJIS basic sun.nio.cs.ext true 0x81 0xfc 0x40 0xfc +PCK x-PCK PCK basic sun.nio.cs.ext true 0x81 0xfc 0x40 0xfc +IBM1364 x-IBM1364 Cp1364 ebcdic sun.nio.cs.ext false 0x40 0xde 0x40 0xfe +IBM1381 x-IBM1381 Cp1381 basic sun.nio.cs.ext true 0x8c 0xf7 0xa1 0xfe +IBM1383 x-IBM1383 Cp1383 euc_sim sun.nio.cs.ext true 0xa1 0xfe 0xa1 0xfe +IBM300 x-IBM300 Cp300 dbcsonly sun.nio.cs.ext false 0x40 0x7f 0x40 0xfe +IBM930 x-IBM930 Cp930 ebcdic sun.nio.cs.ext false 0x40 0x7f 0x40 0xfe +IBM933 x-IBM933 Cp933 ebcdic sun.nio.cs.ext false 0x40 0xdd 0x40 0xfe +IBM935 x-IBM935 Cp935 ebcdic sun.nio.cs.ext false 0x40 0x7f 0x40 0xfe +IBM937 x-IBM937 Cp937 ebcdic sun.nio.cs.ext false 0x40 0xe2 0x40 0xfe +IBM939 x-IBM939 Cp939 ebcdic sun.nio.cs.ext false 0x40 0x7f 0x40 0xfe +IBM942 x-IBM942 Cp942 basic sun.nio.cs.ext false 0x81 0xfc 0x40 0xfc +IBM943 x-IBM943 Cp943 basic sun.nio.cs.ext false 0x81 0xfc 0x40 0xfc +IBM948 x-IBM948 Cp948 basic sun.nio.cs.ext true 0x81 0xfe 0x40 0xfc +IBM949 x-IBM949 Cp949 basic sun.nio.cs.ext false 0x8f 0xfe 0xa1 0xfe +IBM950 x-IBM950 Cp950 basic sun.nio.cs.ext true 0x81 0xfe 0x40 0xfe +IBM970 x-IBM970 Cp970 euc_sim sun.nio.cs.ext true 0xa1 0xfe 0xa1 0xfe +JIS_X_0208 x-JIS0208 JIS0208 dbcsonly sun.nio.cs.ext false 0x21 0x7e 0x21 0x7e +JIS_X_0212 JIS_X0212-1990 JIS0212 dbcsonly sun.nio.cs.ext false 0x21 0x7e 0x21 0x7e +JIS_X_0208_Solaris x-JIS0208_Solaris JIS0208_Solaris dbcsonly sun.nio.cs.ext false 0x21 0x9e 0x21 0x7e +JIS_X_0208_MS5022X x-JIS0208_MS5022X JIS0208_MS5022X dbcsonly sun.nio.cs.ext false 0x21 0x7e 0x21 0x7e +JIS_X_0208_MS932 x-JIS0208_MS932 JIS0208_MS932 dbcsonly sun.nio.cs.ext false 0x21 0x7e 0x21 0x7e +JIS_X_0212_Solaris x-JIS0212_Solaris JIS0212_Solaris dbcsonly sun.nio.cs.ext false 0x21 0x7e 0x21 0x7e +JIS_X_0212_MS5022X x-JIS0212_MS5022X JIS0212_MS5022X dbcsonly sun.nio.cs.ext false 0x21 0x7e 0x21 0x7e --- old/make/data/charsetmapping/dbcs 2015-02-16 10:40:57.000000000 -0800 +++ /dev/null 2014-05-19 13:38:05.886368312 -0700 @@ -1,36 +0,0 @@ -# -#clzName csName hisName dbtype pkg ascii b1min b1max b2min b2max -# -Big5 Big5 Big5 basic sun.nio.cs.ext true 0xa1 0xf9 0x40 0xfe -Johab x-Johab x-Johab basic sun.nio.cs.ext true 0x84 0xf9 0x31 0xfe -EUC_CN GB2312 EUC_CN basic sun.nio.cs.ext true 0xa1 0xf7 0xa1 0xfe -EUC_KR EUC-KR EUC_KR basic sun.nio.cs.ext true 0xa1 0xfd 0xa1 0xfe -MS932 windows-31j MS932 basic sun.nio.cs.ext true 0x81 0xfc 0x40 0xfc -MS936 x-mswin-936 MS936 basic sun.nio.cs.ext true 0x81 0xfe 0x40 0xfe -MS949 x-windows-949 MS949 basic sun.nio.cs.ext true 0x81 0xfe 0x41 0xfe -MS950 x-windows-950 MS950 basic sun.nio.cs.ext true 0x81 0xfe 0x40 0xfe -GBK GBK GBK basic sun.nio.cs.ext true 0x81 0xfe 0x40 0xfe -SJIS Shift_JIS SJIS basic sun.nio.cs.ext true 0x81 0xfc 0x40 0xfc -PCK x-PCK PCK basic sun.nio.cs.ext true 0x81 0xfc 0x40 0xfc -IBM1364 x-IBM1364 Cp1364 ebcdic sun.nio.cs.ext false 0x40 0xde 0x40 0xfe -IBM1381 x-IBM1381 Cp1381 basic sun.nio.cs.ext true 0x8c 0xf7 0xa1 0xfe -IBM1383 x-IBM1383 Cp1383 euc_sim sun.nio.cs.ext true 0xa1 0xfe 0xa1 0xfe -IBM300 x-IBM300 Cp300 dbcsonly sun.nio.cs.ext false 0x40 0x7f 0x40 0xfe -IBM930 x-IBM930 Cp930 ebcdic sun.nio.cs.ext false 0x40 0x7f 0x40 0xfe -IBM933 x-IBM933 Cp933 ebcdic sun.nio.cs.ext false 0x40 0xdd 0x40 0xfe -IBM935 x-IBM935 Cp935 ebcdic sun.nio.cs.ext false 0x40 0x7f 0x40 0xfe -IBM937 x-IBM937 Cp937 ebcdic sun.nio.cs.ext false 0x40 0xe2 0x40 0xfe -IBM939 x-IBM939 Cp939 ebcdic sun.nio.cs.ext false 0x40 0x7f 0x40 0xfe -IBM942 x-IBM942 Cp942 basic sun.nio.cs.ext false 0x81 0xfc 0x40 0xfc -IBM943 x-IBM943 Cp943 basic sun.nio.cs.ext false 0x81 0xfc 0x40 0xfc -IBM948 x-IBM948 Cp948 basic sun.nio.cs.ext true 0x81 0xfe 0x40 0xfc -IBM949 x-IBM949 Cp949 basic sun.nio.cs.ext false 0x8f 0xfe 0xa1 0xfe -IBM950 x-IBM950 Cp950 basic sun.nio.cs.ext true 0x81 0xfe 0x40 0xfe -IBM970 x-IBM970 Cp970 euc_sim sun.nio.cs.ext true 0xa1 0xfe 0xa1 0xfe -JIS_X_0208 x-JIS0208 JIS0208 dbcsonly sun.nio.cs.ext false 0x21 0x7e 0x21 0x7e -JIS_X_0212 JIS_X0212-1990 JIS0212 dbcsonly sun.nio.cs.ext false 0x21 0x7e 0x21 0x7e -JIS_X_0208_Solaris x-JIS0208_Solaris JIS0208_Solaris dbcsonly sun.nio.cs.ext false 0x21 0x9e 0x21 0x7e -JIS_X_0208_MS5022X x-JIS0208_MS5022X JIS0208_MS5022X dbcsonly sun.nio.cs.ext false 0x21 0x7e 0x21 0x7e -JIS_X_0208_MS932 x-JIS0208_MS932 JIS0208_MS932 dbcsonly sun.nio.cs.ext false 0x21 0x7e 0x21 0x7e -JIS_X_0212_Solaris x-JIS0212_Solaris JIS0212_Solaris dbcsonly sun.nio.cs.ext false 0x21 0x7e 0x21 0x7e -JIS_X_0212_MS5022X x-JIS0212_MS5022X JIS0212_MS5022X dbcsonly sun.nio.cs.ext false 0x21 0x7e 0x21 0x7e --- old/make/data/charsetmapping/extsbcs 2015-02-16 10:40:58.000000000 -0800 +++ /dev/null 2014-05-19 13:38:05.886368312 -0700 @@ -1,76 +0,0 @@ -# clzName csName hisName containASCII pkg -IBM037 IBM037 Cp037 false sun.nio.cs.ext -IBM1006 x-IBM1006 Cp1006 false sun.nio.cs.ext -IBM1025 x-IBM1025 Cp1025 false sun.nio.cs.ext -IBM1026 IBM1026 Cp1026 false sun.nio.cs.ext -IBM1046 x-IBM1046 Cp1046 false sun.nio.cs.ext -IBM1047 IBM1047 Cp1047 false sun.nio.cs.ext -IBM1097 x-IBM1097 Cp1097 false sun.nio.cs.ext -IBM1098 x-IBM1098 Cp1098 false sun.nio.cs.ext -IBM1112 x-IBM1112 Cp1112 false sun.nio.cs.ext -IBM1122 x-IBM1122 Cp1122 false sun.nio.cs.ext -IBM1123 x-IBM1123 Cp1123 false sun.nio.cs.ext -IBM1124 x-IBM1124 Cp1124 false sun.nio.cs.ext -# map tables for 1140-1149 are updated manualy with the u+20ac entry -IBM1140 IBM01140 Cp1140 false sun.nio.cs.ext -IBM1141 IBM01141 Cp1141 false sun.nio.cs.ext -IBM1142 IBM01142 Cp1142 false sun.nio.cs.ext -IBM1143 IBM01143 Cp1143 false sun.nio.cs.ext -IBM1144 IBM01144 Cp1144 false sun.nio.cs.ext -IBM1145 IBM01145 Cp1145 false sun.nio.cs.ext -IBM1146 IBM01146 Cp1146 false sun.nio.cs.ext -IBM1147 IBM01147 Cp1147 false sun.nio.cs.ext -IBM1148 IBM01148 Cp1148 false sun.nio.cs.ext -IBM1149 IBM01149 Cp1149 false sun.nio.cs.ext -IBM273 IBM273 Cp273 false sun.nio.cs.ext -IBM277 IBM277 Cp277 false sun.nio.cs.ext -IBM278 IBM278 Cp278 false sun.nio.cs.ext -IBM280 IBM280 Cp280 false sun.nio.cs.ext -IBM284 IBM284 Cp284 false sun.nio.cs.ext -IBM285 IBM285 Cp285 false sun.nio.cs.ext -IBM290 IBM290 Cp290 false sun.nio.cs.ext -IBM297 IBM297 Cp297 false sun.nio.cs.ext -IBM420 IBM420 Cp420 false sun.nio.cs.ext -IBM424 IBM424 Cp424 false sun.nio.cs.ext -IBM500 IBM500 Cp500 false sun.nio.cs.ext -IBM833 x-IBM833 Cp833 false sun.nio.cs.ext -IBM838 IBM-Thai Cp838 false sun.nio.cs.ext -IBM856 x-IBM856 Cp856 false sun.nio.cs.ext -IBM860 IBM860 Cp860 false sun.nio.cs.ext -IBM861 IBM861 Cp861 false sun.nio.cs.ext -IBM863 IBM863 Cp863 false sun.nio.cs.ext -IBM864 IBM864 Cp864 false sun.nio.cs.ext -IBM865 IBM865 Cp865 false sun.nio.cs.ext -IBM868 IBM868 Cp868 false sun.nio.cs.ext -IBM869 IBM869 Cp869 false sun.nio.cs.ext -IBM870 IBM870 Cp870 false sun.nio.cs.ext -IBM871 IBM871 Cp871 false sun.nio.cs.ext -IBM875 x-IBM875 Cp875 false sun.nio.cs.ext -IBM918 IBM918 Cp918 false sun.nio.cs.ext -IBM921 x-IBM921 Cp921 false sun.nio.cs.ext -IBM922 x-IBM922 Cp922 false sun.nio.cs.ext -# use name as hisname as well, cs did not support hisname prevously -ISO_8859_11 x-iso-8859-11 x-iso-8859-11 true sun.nio.cs.ext -ISO_8859_3 ISO-8859-3 ISO8859_3 true sun.nio.cs.ext -ISO_8859_6 ISO-8859-6 ISO8859_6 true sun.nio.cs.ext -ISO_8859_8 ISO-8859-8 ISO8859_8 true sun.nio.cs.ext -JIS_X_0201 JIS_X0201 JIS_X0201 true sun.nio.cs.ext -MS1255 windows-1255 Cp1255 true sun.nio.cs.ext -MS1256 windows-1256 Cp1256 true sun.nio.cs.ext -MS1258 windows-1258 Cp1258 true sun.nio.cs.ext -MS874 x-windows-874 MS874 true sun.nio.cs.ext -MacArabic x-MacArabic MacArabic false sun.nio.cs.ext -MacCentralEurope x-MacCentralEurope MacCentralEurope false sun.nio.cs.ext -MacCroatian x-MacCroatian MacCroatian false sun.nio.cs.ext -MacCyrillic x-MacCyrillic MacCyrillic false sun.nio.cs.ext -MacDingbat x-MacDingbat MacDingbat false sun.nio.cs.ext -MacGreek x-MacGreek MacGreek false sun.nio.cs.ext -MacHebrew x-MacHebrew MacHebrew false sun.nio.cs.ext -MacIceland x-MacIceland MacIceland false sun.nio.cs.ext -MacRoman x-MacRoman MacRoman false sun.nio.cs.ext -MacRomania x-MacRomania MacRomania false sun.nio.cs.ext -MacSymbol x-MacSymbol MacSymbol false sun.nio.cs.ext -MacThai x-MacThai MacThai false sun.nio.cs.ext -MacTurkish x-MacTurkish MacTurkish false sun.nio.cs.ext -MacUkraine x-MacUkraine MacUkraine false sun.nio.cs.ext -TIS_620 TIS-620 TIS620 true sun.nio.cs.ext --- old/make/data/charsetmapping/sbcs 2015-02-16 10:40:59.000000000 -0800 +++ /dev/null 2014-05-19 13:38:05.886368312 -0700 @@ -1,28 +0,0 @@ -# clzName csName hisName containASCII pkg -IBM437 IBM437 Cp437 false sun.nio.cs -IBM737 x-IBM737 Cp737 false sun.nio.cs -IBM775 IBM775 Cp775 false sun.nio.cs -IBM850 IBM850 Cp850 false sun.nio.cs -IBM852 IBM852 Cp852 false sun.nio.cs -IBM855 IBM855 Cp855 false sun.nio.cs -IBM857 IBM857 Cp857 false sun.nio.cs -IBM858 IBM00858 Cp858 false sun.nio.cs -IBM862 IBM862 Cp862 false sun.nio.cs -IBM866 IBM866 Cp866 false sun.nio.cs -IBM874 x-IBM874 Cp874 false sun.nio.cs -ISO_8859_2 ISO-8859-2 ISO8859_2 true sun.nio.cs -ISO_8859_4 ISO-8859-4 ISO8859_4 true sun.nio.cs -ISO_8859_5 ISO-8859-5 ISO8859_5 true sun.nio.cs -ISO_8859_7 ISO-8859-7 ISO8859_7 true sun.nio.cs -ISO_8859_9 ISO-8859-9 ISO8859_9 true sun.nio.cs -ISO_8859_13 ISO-8859-13 ISO8859_13 true sun.nio.cs -ISO_8859_15 ISO-8859-15 ISO8859_15 true sun.nio.cs -KOI8_R KOI8-R KOI8_R true sun.nio.cs -KOI8_U KOI8-U KOI8_U true sun.nio.cs -MS1250 windows-1250 Cp1250 true sun.nio.cs -MS1251 windows-1251 Cp1251 true sun.nio.cs -MS1252 windows-1252 Cp1252 true sun.nio.cs -MS1253 windows-1253 Cp1253 true sun.nio.cs -MS1254 windows-1254 Cp1254 true sun.nio.cs -MS1257 windows-1257 Cp1257 true sun.nio.cs - --- old/make/data/charsetmapping/standard-charsets 2015-02-16 10:41:00.000000000 -0800 +++ /dev/null 2014-05-19 13:38:05.886368312 -0700 @@ -1,337 +0,0 @@ -# -# Copyright (c) 2000, 2014, 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. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# 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. -# - -# Standard charsets provided by StandardCharsets provider. -# -# Note that these "standard" charsets listed here are not -# necessary to be the "Standard charsets" defined in the -# specification of java.nio.charset.Charset. Instead these -# are the charsets that this implementation believes should -# be packaged into the charsets provider class "StandardCharsets" -# which is initialized at startup time by java.nio.charset.Charset, -# compared to the charsets packaged in "ExtendedCharsets" provider, -# which is lazy initialized. - -charset US-ASCII US_ASCII - - # IANA aliases - alias iso-ir-6 - alias ANSI_X3.4-1986 - alias ISO_646.irv:1991 - alias ASCII - alias ISO646-US - alias us - alias IBM367 - alias cp367 - alias csASCII - alias default - - # Other aliases - alias 646 # Solaris POSIX locale - alias iso_646.irv:1983 - alias ANSI_X3.4-1968 # Linux POSIX locale (RedHat) - alias ascii7 - -charset UTF-8 UTF_8 - alias UTF8 # JDK historical - alias unicode-1-1-utf-8 - -charset CESU-8 CESU_8 - alias CESU8 - alias csCESU-8 - -charset UTF-16 UTF_16 - alias UTF_16 # JDK historical - alias utf16 - alias unicode - alias UnicodeBig - -charset UTF-16BE UTF_16BE - alias UTF_16BE - alias ISO-10646-UCS-2 - alias X-UTF-16BE - alias UnicodeBigUnmarked - -charset UTF-16LE UTF_16LE - alias UTF_16LE - alias X-UTF-16LE - alias UnicodeLittleUnmarked - -charset x-UTF-16LE-BOM UTF_16LE_BOM - alias UnicodeLittle - -charset UTF-32 UTF_32 - alias UTF_32 - alias UTF32 - -charset UTF-32LE UTF_32LE - alias UTF_32LE - alias X-UTF-32LE - -charset UTF-32BE UTF_32BE - alias UTF_32BE - alias X-UTF-32BE - -charset X-UTF-32LE-BOM UTF_32LE_BOM - alias UTF_32LE_BOM - alias UTF-32LE-BOM - -charset X-UTF-32BE-BOM UTF_32BE_BOM - alias UTF_32BE_BOM - alias UTF-32BE-BOM - -charset ISO-8859-1 ISO_8859_1 - - # IANA aliases - alias iso-ir-100 - alias ISO_8859-1 - alias latin1 - alias l1 - alias IBM819 - alias cp819 - alias csISOLatin1 - - # Other aliases - alias 819 - alias IBM-819 - alias ISO8859_1 - alias ISO_8859-1:1987 - alias ISO_8859_1 - alias 8859_1 - alias ISO8859-1 - -charset ISO-8859-2 ISO_8859_2 - alias iso8859_2 # JDK historical - alias 8859_2 - alias iso-ir-101 - alias ISO_8859-2 - alias ISO_8859-2:1987 - alias ISO8859-2 - alias latin2 - alias l2 - alias ibm912 - alias ibm-912 - alias cp912 - alias 912 - alias csISOLatin2 - -charset ISO-8859-4 ISO_8859_4 - alias iso8859_4 # JDK historical - alias iso8859-4 - alias 8859_4 - alias iso-ir-110 - alias ISO_8859-4 - alias ISO_8859-4:1988 - alias latin4 - alias l4 - alias ibm914 - alias ibm-914 - alias cp914 - alias 914 - alias csISOLatin4 - -charset ISO-8859-5 ISO_8859_5 - alias iso8859_5 # JDK historical - alias 8859_5 - alias iso-ir-144 - alias ISO_8859-5 - alias ISO_8859-5:1988 - alias ISO8859-5 - alias cyrillic - alias ibm915 - alias ibm-915 - alias cp915 - alias 915 - alias csISOLatinCyrillic - -charset ISO-8859-7 ISO_8859_7 - alias iso8859_7 # JDK historical - alias 8859_7 - alias iso-ir-126 - alias ISO_8859-7 - alias ISO_8859-7:1987 - alias ELOT_928 - alias ECMA-118 - alias greek - alias greek8 - alias csISOLatinGreek - alias sun_eu_greek # Solaris 7/8 compatibility - alias ibm813 - alias ibm-813 - alias 813 - alias cp813 - alias iso8859-7 # Solaris 9 compatibility - -charset ISO-8859-9 ISO_8859_9 - alias iso8859_9 # JDK historical - alias 8859_9 - alias iso-ir-148 - alias ISO_8859-9 - alias ISO_8859-9:1989 - alias ISO8859-9 - alias latin5 - alias l5 - alias ibm920 - alias ibm-920 - alias 920 - alias cp920 - alias csISOLatin5 - -charset ISO-8859-13 ISO_8859_13 - alias iso8859_13 # JDK historical - alias 8859_13 - alias iso_8859-13 - alias ISO8859-13 - -charset ISO-8859-15 ISO_8859_15 - - # IANA alias - alias ISO_8859-15 - - # Other aliases - alias 8859_15 - alias ISO-8859-15 - alias ISO8859_15 - alias ISO8859-15 - alias IBM923 - alias IBM-923 - alias cp923 - alias 923 - alias LATIN0 - alias LATIN9 - alias L9 - alias csISOlatin0 - alias csISOlatin9 - alias ISO8859_15_FDIS - -charset KOI8-R KOI8_R - alias koi8_r # JDK historical - alias koi8 - alias cskoi8r - -charset KOI8-U KOI8_U - alias koi8_u - -charset windows-1250 MS1250 - alias cp1250 # JDK historical - alias cp5346 # Euro IBM CCSID - -charset windows-1251 MS1251 - alias cp1251 # JDK historical - alias cp5347 # Euro IBM CCSID - alias ansi-1251 # Solaris compatibility - -charset windows-1252 MS1252 - alias cp1252 # JDK historical - alias cp5348 # Euro IBM CCSID - -charset windows-1253 MS1253 - alias cp1253 # JDK historical - alias cp5349 # Euro IBM CCSID - -charset windows-1254 MS1254 - alias cp1254 # JDK historical - alias cp5350 # Euro IBM CCSID - -charset windows-1257 MS1257 - alias cp1257 # JDK historical - alias cp5353 # Euro IBM CCSID - - -charset IBM437 IBM437 - alias cp437 #JDK historical - alias ibm437 - alias ibm-437 - alias 437 - alias cspc8codepage437 - alias windows-437 - -charset x-IBM737 IBM737 - alias cp737 #JDK historical - alias ibm737 - alias ibm-737 - alias 737 - -charset IBM775 IBM775 - alias cp775 #JDK historical - alias ibm775 - alias ibm-775 - alias 775 - -charset IBM850 IBM850 - alias cp850 #JDK historical - alias ibm-850 - alias ibm850 - alias 850 - alias cspc850multilingual - -charset IBM852 IBM852 - alias cp852 #JDK historical - alias ibm852 - alias ibm-852 - alias 852 - alias csPCp852 - -charset IBM855 IBM855 - alias cp855 #JDK historical - alias ibm-855 - alias ibm855 - alias 855 - alias cspcp855 - -charset IBM857 IBM857 - alias cp857 #JDK historical - alias ibm857 - alias ibm-857 - alias 857 - alias csIBM857 - -charset IBM00858 IBM858 - alias cp858 #JDK historical - alias ccsid00858 - alias cp00858 - alias 858 - alias PC-Multilingual-850+euro - -charset IBM862 IBM862 - alias cp862 #JDK historical - alias ibm862 - alias ibm-862 - alias 862 - alias csIBM862 - alias cspc862latinhebrew - -charset IBM866 IBM866 - alias cp866 #JDK historical - alias ibm866 - alias ibm-866 - alias 866 - alias csIBM866 - -charset x-IBM874 IBM874 - alias cp874 #JDK historical - alias ibm874 - alias ibm-874 - alias 874 --- old/make/data/charsetmapping/DoubleByte-X.java.template 2015-02-16 10:41:01.000000000 -0800 +++ new/make/data/charsetmapping/DoubleByte-X.java.template 2015-02-16 10:41:00.000000000 -0800 @@ -32,7 +32,8 @@ import java.nio.charset.CharsetEncoder; import java.util.Arrays; import sun.nio.cs.HistoricallyNamedCharset; -import sun.nio.cs.ext.DoubleByte; +import sun.nio.cs.DoubleByte; +import sun.nio.cs.*; public class $NAME_CLZ$ extends Charset $IMPLEMENTS$ --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/make/src/classes/build/tools/charsetmapping/Charset.java 2015-02-16 10:41:01.000000000 -0800 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package build.tools.charsetmapping; + +class Charset { + String pkgName; + String clzName; + String csName; + String hisName; + String type; + boolean isASCII; + int b1Min; + int b1Max; + int b2Min; + int b2Max; + String[] aliases; + boolean isGenSrc = false; + boolean isInternal = false; +} + --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/make/src/classes/build/tools/charsetmapping/Hasher.java 2015-02-16 10:41:03.000000000 -0800 @@ -0,0 +1,265 @@ +/* + * Copyright (c) 2004, 2013, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package build.tools.charsetmapping; + +import java.io.*; +import java.util.*; + + +/** + * Reads a map in the form of a sequence of key/value-expression pairs from the + * standard input, attempts to construct a hash map that fits within the given + * table-size and chain-depth constraints, and, if successful, writes source + * code to the standard output for a subclass of sun.util.PreHashedMap that + * implements the map. + * + * @see sun.util.PreHashedMap + * + * @author Mark Reinhold + */ + +public class Hasher { + + private PrintStream err = System.err; + + boolean verbose = false; + List keys = new ArrayList<>(); // Key strings + List values = new ArrayList<>(); // Value expressions + String pkg = null; // Package prefix for generated class + String cln = null; // Name of generated class + String vtype = null; // Value type + int maxBits = 11; // lg table size + int maxDepth = 3; // Max chain depth + boolean inner = false; // Generating an inner class? + boolean empty = false; // Generating an empty table? + + Object[] ht; // Hash table itself + int nb; // Number of bits (lg table size) + int md; // Maximum chain depth + int mask; // Hash-code mask + int shift; // Hash-code shift size + + int hash(String w) { + return (w.hashCode() >> shift) & mask; + } + + // Build a hash table of size 2^nb, shifting the hash code by s bits + // + void build(int nb, int s) { + + this.nb = nb; + this.shift = s; + int n = 1 << nb; + this.mask = n - 1; + ht = new Object[n]; + int nw = keys.size(); + + for (int i = 0; i < nw; i++) { + String w = keys.get(i); + String v = values.get(i); + int h = hash(w); + if (ht[h] == null) + ht[h] = new Object[] { w, v }; + else + ht[h] = new Object[] { w, v, ht[h] }; + } + + this.md = 0; + for (int i = 0; i < n; i++) { + int d = 1; + for (Object[] a = (Object[])ht[i]; + a != null && a.length > 2; + a = (Object[])a[2], d++); + this.md = Math.max(md, d); + } + + } + + Hasher build() { + // Iterate through acceptable table sizes + for (int nb = 2; nb < maxBits; nb++) { + // Iterate through possible shift sizes + for (int s = 0; s < (32 - nb); s++) { + build(nb, s); + if (verbose) + err.println("nb=" + nb + " s=" + s + " md=" + md); + if (md <= maxDepth) { + // Success + if (verbose) { + if (cln != null) + err.print(cln + ": "); + err.println("Table size " + (1 << nb) + " (" + nb + " bits)" + + ", shift " + shift + + ", max chain depth " + md); + } + return this; + } + } + } + throw new RuntimeException("Cannot find a suitable size" + + " within given constraints"); + } + + // Look for the given key in the hash table + // + String get(String k) { + int h = hash(k); + Object[] a = (Object[])ht[h]; + for (;;) { + if (a[0].equals(k)) + return (String)a[1]; + if (a.length < 3) + return null; + a = (Object[])a[2]; + } + } + + // Test that all input keys can be found in the table + // + Hasher test() { + if (verbose) + err.println(); + for (int i = 0, n = keys.size(); i < n; i++) { + String w = keys.get(i); + String v = get(w); + if (verbose) + err.println(hash(w) + "\t" + w); + if (!v.equals(values.get(i))) + throw new Error("Incorrect value: " + w + " --> " + + v + ", should be " + values.get(i)); + } + return this; + } + + String ind = ""; // Indent prefix + + // Generate code for a single table entry + // + void genEntry(Object[] a, int depth, PrintStream out) { + Object v = empty ? null : a[1]; + out.print("new Object[] { \"" + a[0] + "\", " + v); + if (a.length < 3) { + out.print(" }"); + return; + } + out.println(","); + out.print(ind + " "); + for (int i = 0; i < depth; i++) + out.print(" "); + genEntry((Object[])a[2], depth + 1, out); + out.print(" }"); + } + + // Generate a PreHashedMap subclass from the computed hash table + // + Hasher generate(PrintStream out) throws IOException { + if (cln == null) + return this; + + if (inner) + ind = " "; + + if (!inner && pkg != null) { + out.println(); + out.println("package " + pkg + ";"); + out.println(); + } + + if (inner) { + out.println(ind + "private static final class " + cln); + } else { + out.println(); + out.println("public final class " + cln); + } + out.println(ind + " extends sun.util.PreHashedMap<" + vtype +">"); + out.println(ind + "{"); + + out.println(); + out.println(ind + " private static final int ROWS = " + + ht.length + ";"); + out.println(ind + " private static final int SIZE = " + + keys.size() + ";"); + out.println(ind + " private static final int SHIFT = " + + shift + ";"); + out.println(ind + " private static final int MASK = 0x" + + Integer.toHexString(mask) + ";"); + out.println(); + + out.println(ind + " " + (inner ? "private " : "public ") + + cln + "() {"); + out.println(ind + " super(ROWS, SIZE, SHIFT, MASK);"); + out.println(ind + " }"); + out.println(); + + out.println(ind + " protected void init(Object[] ht) {"); + for (int i = 0; i < ht.length; i++) { + if (ht[i] == null) + continue; + Object[] a = (Object[])ht[i]; + out.print(ind + " ht[" + i + "] = "); + genEntry(a, 0, out); + out.println(";"); + } + out.println(ind + " }"); + out.println(); + + out.println(ind + "}"); + if (inner) + out.println(); + + return this; + } + + private Hasher(List keys, List values, + String pkg, String cln, String vtype, + int maxBits, int maxDepth, + boolean inner, boolean empty, + boolean verbose) { + this.keys = keys; + this.values = values; + this.pkg = pkg; + this.cln = cln; + this.vtype = vtype; + this.maxBits = maxBits; + this.maxDepth = maxDepth; + this.inner = inner; + this.empty = empty; + this.verbose = verbose; + } + + public static void genClass(PrintStream out, + List keys, List values, + String pkg, String cln, String vtype, + int maxBits, int maxDepth, + boolean inner, boolean empty, boolean verbose) + throws IOException { + new Hasher(keys, values, pkg, cln, vtype, + maxBits, maxDepth, inner, empty, verbose) + .build() + .test() + .generate(out); + } +} --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/make/src/classes/build/tools/charsetmapping/SPI.java 2015-02-16 10:41:04.000000000 -0800 @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2015, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package build.tools.charsetmapping; + +import java.io.*; +import java.util.Locale; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.Scanner; + +public class SPI { + + public static void genClass(String type, LinkedHashMap charsets, + String srcDir, String dstDir, String template) + throws Exception + { + try (Scanner s = new Scanner(new File(template)); + PrintStream out = new PrintStream(new FileOutputStream( + new File(dstDir, new File( + template.replace(".template", "")).getName()))); ) { + if (type.startsWith("extcs")) { // ExtendedCharsets.java + while (s.hasNextLine()) { + String line = s.nextLine(); + if (line.indexOf("_CHARSETS_DEF_LIST_") == -1) { + out.println(line); + } else { + charsets.values() + .stream() + .filter(cs -> cs.pkgName.equals("sun.nio.cs.ext") && + !cs.isInternal) + .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 + ArrayList aliasKeys = new ArrayList<>(); + ArrayList aliasValues = new ArrayList<>(); + ArrayList clzKeys = new ArrayList<>(); + ArrayList clzValues = new ArrayList<>(); + charsets.values() + .stream() + .filter(cs -> cs.pkgName.equals("sun.nio.cs") && + !cs.isInternal) + .forEach( cs -> { + String csname = cs.csName.toLowerCase(Locale.ENGLISH); + clzKeys.add(csname); + clzValues.add("\"" + cs.clzName + "\""); + if (cs.aliases != null) { + csname = "\"" + csname + "\""; + for (String alias : cs.aliases) { + aliasKeys.add(alias.toLowerCase(Locale.ENGLISH)); + aliasValues.add(csname); + } + } + }); + while (s.hasNextLine()) { + String line = s.nextLine(); + if (line.indexOf("_INCLUDE_ALIASES_TABLES_") != -1) { + charsets.values() + .stream() + .filter(cs -> cs.pkgName.equals("sun.nio.cs")) + .forEach( cs -> { + if (cs.aliases == null || cs.aliases.length == 0) { + out.printf(" static final String[] aliases_%s = null;%n%n", + cs.clzName); + } else { + // non-final for SJIS and MS932 to support sun.nio.cs.map + if (cs.clzName.equals("SJIS") || cs.clzName.equals("MS932")) { + out.printf(" static String[] aliases_%s = new String[] {%n", + cs.clzName); + } else { + out.printf(" static final String[] aliases_%s = new String[] {%n", + cs.clzName); + } + for (String alias : cs.aliases) { + out.printf(" \"%s\",%n", alias); + } + out.printf(" };%n%n"); + } + }); + Charset cs = charsets.get("SJIS"); + if (cs == null || cs.pkgName.equals("sun.nio.cs.ext")) { + // StandardCharsets.java has explicit reference + // to aliases_SJIS/MS932. If we don't have these + // two in std, just put a pair of dummy fields to + // make the compiler happy. + out.printf(" static String[] aliases_SJIS = null;%n%n"); + out.printf(" static String[] aliases_MS932 = null;%n%n"); + } + } else if (line.indexOf("_INCLUDE_ALIASES_MAP_") != -1) { + Hasher.genClass(out, aliasKeys, aliasValues, + null, "Aliases", "String", + 11, 3, true, false, false); + } else if (line.indexOf("_INCLUDE_CLASSES_MAP_") != -1) { + Hasher.genClass(out, clzKeys, clzValues, + null, "Classes", "String", + 11, 3, true, false, false); + } else if (line.indexOf("_INCLUDE_CACHE_MAP_") != -1) { + Hasher.genClass(out, clzKeys, clzValues, + null, "Cache", "Charset", + 11, 3, true, true, false); + } else { + out.println(line); + } + } + } else { + throw new RuntimeException("Unknown type:" + type); + } + } + + } +} --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/make/src/classes/build/tools/charsetmapping/SRC.java 2015-02-16 10:41:05.000000000 -0800 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2015, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package build.tools.charsetmapping; + +import java.io.*; +import java.util.Scanner; + +public class SRC { + + public static void genClass(Charset cs, String srcDir, String dstDir) + throws Exception + { + String clzName = cs.clzName; + String csName = cs.csName; + String pkgName = cs.pkgName; + + try (Scanner s = new Scanner(new File(srcDir, clzName + ".java.template")); + PrintStream out = new PrintStream(new FileOutputStream( + new File(dstDir, clzName + ".java")));) { + while (s.hasNextLine()) { + String line = s.nextLine(); + if (line.indexOf("$") < 0) { + out.println(line); + continue; + } + if (line.indexOf("$PACKAGE$") != -1) { + out.println(line.replace("$PACKAGE$", pkgName)); + } else if (line.indexOf("$ALIASES$") != -1) { + if ("sun.nio.cs".equals(pkgName)) + out.println(line.replace("$ALIASES$", + "StandardCharsets.aliases_" + clzName)); + else + out.println(line.replace("$ALIASES$", + "ExtendedCharsets.aliasesFor(\"" + csName + "\")")); + } else { + out.println(line); + } + } + } + } +} --- old/make/src/classes/build/tools/charsetmapping/DBCS.java 2015-02-16 10:41:07.000000000 -0800 +++ new/make/src/classes/build/tools/charsetmapping/DBCS.java 2015-02-16 10:41:06.000000000 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2015, 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,71 +24,32 @@ */ package build.tools.charsetmapping; + import java.io.*; import java.util.Arrays; import java.util.ArrayList; import java.util.Scanner; import java.util.Formatter; -import java.util.regex.*; -import java.nio.charset.*; +import java.util.regex.Pattern; import static build.tools.charsetmapping.Utils.*; public class DBCS { // pattern used by this class to read in mapping table static Pattern mPattern = Pattern.compile("(?:0x)?(\\p{XDigit}++)\\s++(?:0x)?(\\p{XDigit}++)(?:\\s++#.*)?"); - public static void genClass(String args[]) throws Exception { - - Scanner s = new Scanner(new File(args[0], args[2])); - while (s.hasNextLine()) { - String line = s.nextLine(); - if (line.startsWith("#") || line.length() == 0) - continue; - String[] fields = line.split("\\s+"); - if (fields.length < 10) { - System.err.println("Misconfiged sbcs line <" + line + ">?"); - continue; - } - String clzName = fields[0]; - String csName = fields[1]; - String hisName = ("null".equals(fields[2]))?null:fields[2]; - String type = fields[3].toUpperCase(); - if ("BASIC".equals(type)) - type = ""; - else - type = "_" + type; - String pkgName = fields[4]; - boolean isASCII = Boolean.valueOf(fields[5]); - int b1Min = toInteger(fields[6]); - int b1Max = toInteger(fields[7]); - int b2Min = toInteger(fields[8]); - int b2Max = toInteger(fields[9]); - System.out.printf("%s,%s,%s,%b,%s%n", clzName, csName, hisName, isASCII, pkgName); - genClass0(args[0], args[1], "DoubleByte-X.java.template", - clzName, csName, hisName, pkgName, - isASCII, type, - b1Min, b1Max, b2Min, b2Max); - } - } - - static int toInteger(String s) { - if (s.startsWith("0x") || s.startsWith("0X")) - return Integer.valueOf(s.substring(2), 16); - else - return Integer.valueOf(s); - } - - private static void genClass0(String srcDir, String dstDir, String template, - String clzName, - String csName, - String hisName, - String pkgName, - boolean isASCII, - String type, - int b1Min, int b1Max, - int b2Min, int b2Max) + public static void genClass(String type, Charset cs, + String srcDir, String dstDir, String template) throws Exception { + String clzName = cs.clzName; + String csName = cs.csName; + String hisName = cs.hisName; + String pkgName = cs.pkgName; + boolean isASCII = cs.isASCII; + int b1Min = cs.b1Min; + int b1Max = cs.b1Max; + int b2Min = cs.b2Min; + int b2Max = cs.b2Max; StringBuilder b2cSB = new StringBuilder(); StringBuilder b2cNRSB = new StringBuilder(); --- old/make/src/classes/build/tools/charsetmapping/HKSCS.java 2015-02-16 10:41:08.000000000 -0800 +++ new/make/src/classes/build/tools/charsetmapping/HKSCS.java 2015-02-16 10:41:07.000000000 -0800 @@ -42,38 +42,51 @@ private static Pattern hkscs = Pattern.compile("(?:0x)?+(\\p{XDigit}++)\\s++(?:0x|U\\+)?+(\\p{XDigit}++)?\\s*+(?:0x|U\\+)?(\\p{XDigit}++)?\\s*+.*"); - static void genClass(String args[]) throws Exception { - + static void genClass2008(String srcDir, String dstDir, String pkgName) + throws Exception + { // hkscs2008 - genClass0(new FileInputStream(new File(args[0], "HKSCS2008.map")), - new FileInputStream(new File(args[0], "HKSCS2008.c2b")), - new PrintStream(new File(args[1], "HKSCSMapping.java"), + genClass0(new FileInputStream(new File(srcDir, "HKSCS2008.map")), + new FileInputStream(new File(srcDir, "HKSCS2008.c2b")), + new PrintStream(new File(dstDir, "HKSCSMapping.java"), "ISO-8859-1"), + pkgName, "HKSCSMapping", - getCopyright(new File(args[3]))); - + true, + ""); + } - // xp2001 - genClass0(new FileInputStream(new File(args[0], "HKSCS_XP.map")), + static void genClassXP(String srcDir, String dstDir, String pkgName) + throws Exception + { + genClass0(new FileInputStream(new File(srcDir, "HKSCS_XP.map")), null, - new PrintStream(new File(args[1], "HKSCS_XPMapping.java"), + new PrintStream(new File(dstDir, "HKSCS_XPMapping.java"), "ISO-8859-1"), + pkgName, "HKSCS_XPMapping", - getCopyright(new File(args[3]))); + false, + ""); + } + static void genClass2001(String args[]) throws Exception { // hkscs2001 genClass0(new FileInputStream(new File(args[0], "HKSCS2001.map")), new FileInputStream(new File(args[0], "HKSCS2001.c2b")), new PrintStream(new File(args[1], "HKSCS2001Mapping.java"), "ISO-8859-1"), + "sun.nio.cs.ext", "HKSCS2001Mapping", + false, getCopyright(new File(args[3]))); } static void genClass0(InputStream isB2C, InputStream isC2B, PrintStream ps, + String pkgName, String clzName, + boolean isPublic, String copyright) throws Exception { @@ -132,8 +145,8 @@ out.format(copyright); out.format("%n// -- This file was mechanically generated: Do not edit! -- //%n"); - out.format("package sun.nio.cs.ext;%n%n"); - out.format("class %s {%n%n", clzName); + out.format("package %s;%n%n", pkgName); + out.format("%sclass %s {%n%n", isPublic ? "public " : "", clzName); /* hardcoded in sun.nio.cs.ext.HKSCS.java out.format(" final static int b1Min = 0x%x;%n", b1Min); @@ -143,7 +156,8 @@ */ // bmp tables - out.format("%n static final String[] b2cBmpStr = new String[] {%n"); + out.format("%n %sstatic final String[] b2cBmpStr = new String[] {%n", + isPublic ? "public " : ""); for (int i = 0; i < 0x100; i++) { if (b2cBmp[i]) out.format(bmp, i, b2Min, b2Max, ","); @@ -153,7 +167,8 @@ out.format(" };%n"); // supp tables - out.format("%n static final String[] b2cSuppStr ="); + out.format("%n %sstatic final String[] b2cSuppStr =", + isPublic ? "public " : ""); if (hasSupp) { out.format(" new String[] {%n"); for (int i = 0; i < 0x100; i++) { @@ -168,7 +183,8 @@ } // private area tables - out.format("%n final static String pua ="); + out.format("%n %sfinal static String pua =", + isPublic ? "public " : ""); if (hasPua) { out.format("%n"); out.format(pua, 0, pua.length, ";"); --- old/make/src/classes/build/tools/charsetmapping/Main.java 2015-02-16 10:41:09.000000000 -0800 +++ new/make/src/classes/build/tools/charsetmapping/Main.java 2015-02-16 10:41:08.000000000 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2015, 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 @@ -26,25 +26,193 @@ package build.tools.charsetmapping; import java.io.*; +import java.util.ArrayList; import java.util.Scanner; +import java.util.LinkedHashMap; +import java.util.Locale; public class Main { - public static void main(String args[]) throws Exception { + public static void main(String args[]) throws Throwable { + int SRC_DIR = 0; + int DST_DIR = 1; + int TYPE = 2; + int CHARSETS = 3; + int OS = 4; + int TEMPLATE = 5; + int EXT_SRC = 6; + if (args.length < 3 ) { - System.out.println("Usage: java -jar charsetmapping.jar src dst mType [copyrightSrc]"); + System.out.println("Usage: java -jar charsetmapping.jar src dst spiType charsets os [template]"); System.exit(1); } - if ("sbcs".equals(args[2]) || "extsbcs".equals(args[2])) { - SBCS.genClass(args); - } else if ("dbcs".equals(args[2])) { - DBCS.genClass(args); - } else if ("euctw".equals(args[2])) { + boolean isStandard = "stdcs".equals(args[TYPE]); + boolean isExtended = "extcs".equals(args[TYPE]); + if (isStandard || isExtended) { + LinkedHashMap charsets = getCharsets( + new File(args[SRC_DIR], args[CHARSETS])); + String[] osStdcs = getOSStdCSList(new File(args[SRC_DIR], args[OS])); + boolean hasBig5_HKSCS = false; + boolean hasMS950_HKSCS_XP = false; + for (String name : osStdcs) { + Charset cs = charsets.get(name); + if (cs != null) { + cs.pkgName = "sun.nio.cs"; + } + if (name.equals("Big5_HKSCS")) { + hasBig5_HKSCS = true; + } else if (name.equals("MS950_HKSCS_XP")) { + hasMS950_HKSCS_XP = true; + } + } + for (Charset cs : charsets.values()) { + if (isStandard && cs.pkgName.equals("sun.nio.cs.ext") || + isExtended && cs.pkgName.equals("sun.nio.cs")) { + continue; + } + verbose(cs); + switch (cs.type) { + case "template": + SRC.genClass(cs, args[EXT_SRC], args[DST_DIR]); + break; + case "sbcs": + SBCS.genClass(cs, args[SRC_DIR], args[DST_DIR], + "SingleByte-X.java.template"); + break; + case "source": + break; // source file, do nothing + default: // dbcs + DBCS.genClass("dbcs".equals(cs.type) ? + "" : "_" + cs.type.toUpperCase(Locale.ENGLISH), + cs, args[SRC_DIR], args[DST_DIR], + "DoubleByte-X.java.template"); + } + } + // provider StandardCharsets.java / ExtendedCharsets.java + SPI.genClass(args[TYPE], charsets, args[SRC_DIR], args[DST_DIR], args[TEMPLATE]); + + // HKSCSMapping2008/XP.java goes together with Big5/MS950XP_HKSCS + if (isStandard && hasBig5_HKSCS || isExtended && !hasBig5_HKSCS) { + HKSCS.genClass2008(args[SRC_DIR], args[DST_DIR], + isStandard ? "sun.nio.cs" : "sun.nio.cs.ext"); + } + if (isStandard && hasMS950_HKSCS_XP || isExtended && !hasMS950_HKSCS_XP) { + HKSCS.genClassXP(args[SRC_DIR], args[DST_DIR], + isStandard ? "sun.nio.cs" : "sun.nio.cs.ext"); + } + } else if ("euctw".equals(args[TYPE])) { EUC_TW.genClass(args); - } else if ("sjis0213".equals(args[2])) { + } else if ("sjis0213".equals(args[TYPE])) { JIS0213.genClass(args); - } else if ("hkscs".equals(args[2])) { - HKSCS.genClass(args); + } else if ("hkscs".equals(args[TYPE])) { + HKSCS.genClass2001(args); + } + } + + private static LinkedHashMap getCharsets(File cslist) + throws Throwable + { + LinkedHashMap charsets = new LinkedHashMap<>(); + try (Scanner s = new Scanner(cslist)) { + Charset cs = null; + ArrayList names = new ArrayList<>(); + while (s.hasNextLine()) { + String line = s.nextLine(); + if (line.startsWith("#") || line.length() == 0) { + continue; + } + String[] tokens = line.split("\\s+"); + if (tokens.length < 2) { + continue; + } + if ("charset".equals(tokens[0])) { + if (cs != null) { + cs.aliases = names.toArray(new String[names.size()]); + charsets.put(cs.clzName, cs); + cs = null; + names.clear(); + } + if (tokens.length < 3) { + throw new RuntimeException("Error: incorrect charset line [" + line + "]"); + } + if ((cs = charsets.get(tokens[2])) != null) { + throw new RuntimeException("Error: deplicate charset line [" + line + "]"); + } + cs = new Charset(); + cs.csName = tokens[1]; + cs.clzName = tokens[2]; + } else { + String key = tokens[1]; // leading empty str + switch (key) { + case "alias": + if (tokens.length < 3) { + throw new RuntimeException("Error: incorrect alias line [" + line + "]"); + } else if (names != null) { + names.add(tokens[2]); // ALIAS_NAME + } + break; + case "package": + cs.pkgName = tokens[2]; + break; + case "type": + cs.type = tokens[2]; + break; + case "hisname": + cs.hisName = tokens[2]; + break; + case "ascii": + cs.isASCII = Boolean.parseBoolean(tokens[2]); + break; + case "minmax": + cs.b1Min = toInteger(tokens[2]); + cs.b1Max = toInteger(tokens[3]); + cs.b2Min = toInteger(tokens[4]); + cs.b2Max = toInteger(tokens[5]); + break; + case "internal": + cs.isInternal = Boolean.parseBoolean(tokens[2]); + break; + default: // ignore + } + } + } + if (cs != null) { + cs.aliases = names.toArray(new String[names.size()]); + charsets.put(cs.clzName, cs); + } + } + return charsets; + } + + private static String[] getOSStdCSList(File stdcsos) throws Throwable + { + ArrayList names = new ArrayList<>(); + if (stdcsos.exists()) { + try (Scanner s = new Scanner(stdcsos)) { + while (s.hasNextLine()) { + String line = s.nextLine(); + int i = line.indexOf('#'); + if (i != -1) { + line = line.substring(0, i); + } + line = line.trim(); + if (line.length() != 0) { + names.add(line); + } + } + } } + return names.toArray(new String[names.size()]); + } + + static void verbose(Charset cs) { + System.err.printf("%s, %s, %s, %s, %s %b%n", + cs.clzName, cs.csName, cs.hisName, cs.pkgName, cs.type, cs.isASCII); + } + + static int toInteger(String s) { + return (s.startsWith("0x") || s.startsWith("0X")) + ? Integer.valueOf(s.substring(2), 16) + : Integer.valueOf(s); } } --- old/make/src/classes/build/tools/charsetmapping/SBCS.java 2015-02-16 10:41:10.000000000 -0800 +++ new/make/src/classes/build/tools/charsetmapping/SBCS.java 2015-02-16 10:41:10.000000000 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, 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 @@ -30,93 +30,23 @@ import java.util.ArrayList; import java.util.Scanner; import java.util.Formatter; -import java.util.regex.*; -import java.nio.charset.*; +import java.util.regex.Pattern; import static build.tools.charsetmapping.Utils.*; public class SBCS { - public static void genClass(String args[]) throws Exception { - - Scanner s = new Scanner(new File(args[0], args[2])); - while (s.hasNextLine()) { - String line = s.nextLine(); - if (line.startsWith("#") || line.length() == 0) - continue; - String[] fields = line.split("\\s+"); - if (fields.length < 5) { - System.err.println("Misconfiged sbcs line <" + line + ">?"); - continue; - } - String clzName = fields[0]; - String csName = fields[1]; - String hisName = fields[2]; - boolean isASCII = Boolean.valueOf(fields[3]); - String pkgName = fields[4]; - System.out.printf("%s,%s,%s,%b,%s%n", clzName, csName, hisName, isASCII, pkgName); - - genClass0(args[0], args[1], "SingleByte-X.java.template", - clzName, csName, hisName, pkgName, isASCII); - } - } - - private static void toString(char[] sb, int off, int end, - Formatter out, String closure, - boolean comment) { - while (off < end) { - out.format(" \""); - for (int j = 0; j < 8; j++) { - if (off == end) - break; - char c = sb[off++]; - switch (c) { - case '\b': - out.format("\\b"); break; - case '\t': - out.format("\\t"); break; - case '\n': - out.format("\\n"); break; - case '\f': - out.format("\\f"); break; - case '\r': - out.format("\\r"); break; - case '\"': - out.format("\\\""); break; - case '\'': - out.format("\\'"); break; - case '\\': - out.format("\\\\"); break; - default: - out.format("\\u%04X", c & 0xffff); - } - } - if (comment) { - if (off == end) - out.format("\" %s // 0x%02x - 0x%02x%n", - closure, off-8, off-1); - else - out.format("\" + // 0x%02x - 0x%02x%n", - off-8, off-1); - } else { - if (off == end) - out.format("\"%s%n", closure); - else - out.format("\" +%n"); - } - } - } - static Pattern sbmap = Pattern.compile("0x(\\p{XDigit}++)\\s++(?:U\\+|0x)?(\\p{XDigit}++)(?:\\s++#.*)?"); - private static void genClass0(String srcDir, String dstDir, - String template, - String clzName, - String csName, - String hisName, - String pkgName, - boolean isASCII) + public static void genClass(Charset cs, + String srcDir, String dstDir, String template) throws Exception { + String clzName = cs.clzName; + String csName = cs.csName; + String hisName = cs.hisName; + String pkgName = cs.pkgName; + boolean isASCII = cs.isASCII; + StringBuilder b2cSB = new StringBuilder(); StringBuilder b2cNRSB = new StringBuilder(); StringBuilder c2bNRSB = new StringBuilder(); @@ -266,4 +196,50 @@ } out.close(); } + + private static void toString(char[] sb, int off, int end, + Formatter out, String closure, boolean comment) + { + while (off < end) { + out.format(" \""); + for (int j = 0; j < 8; j++) { + if (off == end) + break; + char c = sb[off++]; + switch (c) { + case '\b': + out.format("\\b"); break; + case '\t': + out.format("\\t"); break; + case '\n': + out.format("\\n"); break; + case '\f': + out.format("\\f"); break; + case '\r': + out.format("\\r"); break; + case '\"': + out.format("\\\""); break; + case '\'': + out.format("\\'"); break; + case '\\': + out.format("\\\\"); break; + default: + out.format("\\u%04X", c & 0xffff); + } + } + if (comment) { + if (off == end) + out.format("\" %s // 0x%02x - 0x%02x%n", + closure, off-8, off-1); + else + out.format("\" + // 0x%02x - 0x%02x%n", + off-8, off-1); + } else { + if (off == end) + out.format("\"%s%n", closure); + else + out.format("\" +%n"); + } + } + } } --- old/src/java.base/share/classes/sun/nio/cs/StandardCharsets.java.template 2015-02-16 10:41:12.000000000 -0800 +++ new/src/java.base/share/classes/sun/nio/cs/StandardCharsets.java.template 2015-02-16 10:41:11.000000000 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,20 +29,188 @@ package sun.nio.cs; -import java.nio.charset.*; +import java.nio.charset.Charset; +import java.nio.charset.spi.CharsetProvider; +import java.util.Iterator; +import java.util.Locale; +import java.util.Map; +import java.security.AccessController; +import java.security.PrivilegedAction; - -public class StandardCharsets - extends FastCharsetProvider -{ +public class StandardCharsets extends CharsetProvider { _INCLUDE_ALIASES_TABLES_ _INCLUDE_ALIASES_MAP_ _INCLUDE_CLASSES_MAP_ _INCLUDE_CACHE_MAP_ + // Maps canonical names to class names + private Map classMap; + // Maps alias names to canonical names + private Map aliasMap; + // Maps canonical names to cached instances + private Map cache; + + private String packagePrefix = "sun.nio.cs"; + public StandardCharsets() { - super("sun.nio.cs", new Aliases(), new Classes(), new Cache()); + this.aliasMap = new Aliases(); + this.classMap = new Classes(); + this.cache = new Cache(); + } + + private String canonicalize(String csn) { + String acn = aliasMap.get(csn); + return (acn != null) ? acn : csn; + } + + // Private ASCII-only version, optimized for interpretation during startup + // + private static String toLower(String s) { + int n = s.length(); + boolean allLower = true; + for (int i = 0; i < n; i++) { + int c = s.charAt(i); + if (((c - 'A') | ('Z' - c)) >= 0) { + allLower = false; + break; + } + } + if (allLower) + return s; + char[] ca = new char[n]; + for (int i = 0; i < n; i++) { + int c = s.charAt(i); + if (((c - 'A') | ('Z' - c)) >= 0) + ca[i] = (char)(c + 0x20); + else + ca[i] = (char)c; + } + return new String(ca); + } + + private Charset lookup(String charsetName) { + init(); + String csn = canonicalize(toLower(charsetName)); + + // Check cache first + Charset cs = cache.get(csn); + if (cs != null) + return cs; + + // Do we even support this charset? + String cln = classMap.get(csn); + if (cln == null) + return null; + + if (cln.equals("US_ASCII")) { + cs = new US_ASCII(); + cache.put(csn, cs); + return cs; + } + + // Instantiate the charset and cache it + try { + Class c = Class.forName(packagePrefix + "." + cln, + true, + this.getClass().getClassLoader()); + cs = (Charset)c.newInstance(); + cache.put(csn, cs); + return cs; + } catch (ClassNotFoundException | + IllegalAccessException | + InstantiationException x) { + return null; + } + } + + public final Charset charsetForName(String charsetName) { + synchronized (this) { + return lookup(canonicalize(charsetName)); + } + } + + public final Iterator charsets() { + synchronized (this) { + init(); + } + return new Iterator() { + + Iterator i = classMap.keySet().iterator(); + + public boolean hasNext() { + return i.hasNext(); + } + + public Charset next() { + String csn = i.next(); + return lookup(csn); + } + + public void remove() { + throw new UnsupportedOperationException(); + } + + }; + } + + private boolean initialized = false; + + /* provider the sun.nio.cs.map property fir sjis/ms932 mapping hack + */ + private void init() { + if (initialized) + return; + if (!sun.misc.VM.isBooted()) + return; + initialized = true; + + String map = getProperty("sun.nio.cs.map"); + if (map != null) { + String[] maps = map.split(","); + for (int i = 0; i < maps.length; i++) { + if (maps[i].equalsIgnoreCase("Windows-31J/Shift_JIS")) { + // if we dont have both sjis and ms932, do nothing + if (classMap.get("shift_jis") == null || + classMap.get("windows-31j") == null) { + break; + } + aliases_MS932 = new String[] { + "MS932", // JDK historical + "windows-932", + "csWindows31J", + "shift-jis", + "ms_kanji", + "x-sjis", + "csShiftJIS", + // This alias takes precedence over the actual + // Shift_JIS charset itself since aliases are always + // resolved first, before looking up canonical names. + "shift_jis" + }; + aliases_SJIS = new String[] { "sjis" }; + + for (String alias : aliases_MS932) { + aliasMap.put(toLower(alias), "windows-31j"); + } + cache.put("shift_jis", null); + break; + } + } + } } + private static String getProperty(String key) { + // this method may be called during initialization of + // system class loader and thus not using lambda + return AccessController.doPrivileged( + new PrivilegedAction() { + @Override + public String run() { + return System.getProperty(key); + } + }); + } + + } --- old/src/java.base/share/classes/sun/nio/cs/AbstractCharsetProvider.java 2015-02-16 10:41:13.000000000 -0800 +++ new/src/java.base/share/classes/sun/nio/cs/AbstractCharsetProvider.java 2015-02-16 10:41:12.000000000 -0800 @@ -111,6 +111,12 @@ } } + protected boolean hasCharset(String name) { + synchronized (this) { + return classMap.containsKey(name); + } + } + /* Late initialization hook, needed by some providers */ protected void init() { } --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/DelegatableDecoder.java 2015-02-16 10:41:14.000000000 -0800 +++ /dev/null 2014-05-19 13:38:05.886368312 -0700 @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2004, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -package sun.nio.cs.ext; - -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.charset.CoderResult; - -/** - * A decoder that can be delegated to by another decoder - * when normal inheritance cannot be used. - * Used by autodecting decoders. - */ -interface DelegatableDecoder { - CoderResult decodeLoop(ByteBuffer src, CharBuffer dst); - void implReset(); - CoderResult implFlush(CharBuffer out); -} --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/src/java.base/share/classes/sun/nio/cs/DelegatableDecoder.java 2015-02-16 10:41:13.000000000 -0800 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2004, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package sun.nio.cs; + +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.CoderResult; + +/** + * A decoder that can be delegated to by another decoder + * when normal inheritance cannot be used. + * Used by autodecting decoders. + */ +public interface DelegatableDecoder { + CoderResult decodeLoop(ByteBuffer src, CharBuffer dst); + void implReset(); + CoderResult implFlush(CharBuffer out); +} --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/DoubleByte.java 2015-02-16 10:41:15.000000000 -0800 +++ /dev/null 2014-05-19 13:38:05.886368312 -0700 @@ -1,929 +0,0 @@ -/* - * Copyright (c) 2009, 2013, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -package sun.nio.cs.ext; - -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.nio.charset.CharsetEncoder; -import java.nio.charset.CoderResult; -import java.util.Arrays; -import sun.nio.cs.Surrogate; -import sun.nio.cs.ArrayDecoder; -import sun.nio.cs.ArrayEncoder; -import static sun.nio.cs.CharsetMapping.*; - -/* - * Four types of "DoubleByte" charsets are implemented in this class - * (1)DoubleByte - * The "mostly widely used" multibyte charset, a combination of - * a singlebyte character set (usually the ASCII charset) and a - * doublebyte character set. The codepoint values of singlebyte - * and doublebyte don't overlap. Microsoft's multibyte charsets - * and IBM's "DBCS_ASCII" charsets, such as IBM1381, 942, 943, - * 948, 949 and 950 are such charsets. - * - * (2)DoubleByte_EBCDIC - * IBM EBCDIC Mix multibyte charset. Use SO and SI to shift (switch) - * in and out between the singlebyte character set and doublebyte - * character set. - * - * (3)DoubleByte_SIMPLE_EUC - * It's a "simple" form of EUC encoding scheme, only have the - * singlebyte character set G0 and one doublebyte character set - * G1 are defined, G2 (with SS2) and G3 (with SS3) are not used. - * So it is actually the same as the "typical" type (1) mentioned - * above, except it return "malformed" for the SS2 and SS3 when - * decoding. - * - * (4)DoubleByte ONLY - * A "pure" doublebyte only character set. From implementation - * point of view, this is the type (1) with "decodeSingle" always - * returns unmappable. - * - * For simplicity, all implementations share the same decoding and - * encoding data structure. - * - * Decoding: - * - * char[][] b2c; - * char[] b2cSB; - * int b2Min, b2Max - * - * public char decodeSingle(int b) { - * return b2cSB.[b]; - * } - * - * public char decodeDouble(int b1, int b2) { - * if (b2 < b2Min || b2 > b2Max) - * return UNMAPPABLE_DECODING; - * return b2c[b1][b2 - b2Min]; - * } - * - * (1)b2Min, b2Max are the corresponding min and max value of the - * low-half of the double-byte. - * (2)The high 8-bit/b1 of the double-byte are used to indexed into - * b2c array. - * - * Encoding: - * - * char[] c2b; - * char[] c2bIndex; - * - * public int encodeChar(char ch) { - * return c2b[c2bIndex[ch >> 8] + (ch & 0xff)]; - * } - * - */ - -public class DoubleByte { - - public final static char[] B2C_UNMAPPABLE; - static { - B2C_UNMAPPABLE = new char[0x100]; - Arrays.fill(B2C_UNMAPPABLE, UNMAPPABLE_DECODING); - } - - public static class Decoder extends CharsetDecoder - implements DelegatableDecoder, ArrayDecoder - { - final char[][] b2c; - final char[] b2cSB; - final int b2Min; - final int b2Max; - - // for SimpleEUC override - protected CoderResult crMalformedOrUnderFlow(int b) { - return CoderResult.UNDERFLOW; - } - - protected CoderResult crMalformedOrUnmappable(int b1, int b2) { - if (b2c[b1] == B2C_UNMAPPABLE || // isNotLeadingByte(b1) - b2c[b2] != B2C_UNMAPPABLE || // isLeadingByte(b2) - decodeSingle(b2) != UNMAPPABLE_DECODING) { // isSingle(b2) - return CoderResult.malformedForLength(1); - } - return CoderResult.unmappableForLength(2); - } - - Decoder(Charset cs, float avgcpb, float maxcpb, - char[][] b2c, char[] b2cSB, - int b2Min, int b2Max) { - super(cs, avgcpb, maxcpb); - this.b2c = b2c; - this.b2cSB = b2cSB; - this.b2Min = b2Min; - this.b2Max = b2Max; - } - - Decoder(Charset cs, char[][] b2c, char[] b2cSB, int b2Min, int b2Max) { - this(cs, 0.5f, 1.0f, b2c, b2cSB, b2Min, b2Max); - } - - protected CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) { - byte[] sa = src.array(); - int sp = src.arrayOffset() + src.position(); - int sl = src.arrayOffset() + src.limit(); - - char[] da = dst.array(); - int dp = dst.arrayOffset() + dst.position(); - int dl = dst.arrayOffset() + dst.limit(); - - try { - while (sp < sl && dp < dl) { - // inline the decodeSingle/Double() for better performance - int inSize = 1; - int b1 = sa[sp] & 0xff; - char c = b2cSB[b1]; - if (c == UNMAPPABLE_DECODING) { - if (sl - sp < 2) - return crMalformedOrUnderFlow(b1); - int b2 = sa[sp + 1] & 0xff; - if (b2 < b2Min || b2 > b2Max || - (c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) { - return crMalformedOrUnmappable(b1, b2); - } - inSize++; - } - da[dp++] = c; - sp += inSize; - } - return (sp >= sl) ? CoderResult.UNDERFLOW - : CoderResult.OVERFLOW; - } finally { - src.position(sp - src.arrayOffset()); - dst.position(dp - dst.arrayOffset()); - } - } - - protected CoderResult decodeBufferLoop(ByteBuffer src, CharBuffer dst) { - int mark = src.position(); - try { - - while (src.hasRemaining() && dst.hasRemaining()) { - int b1 = src.get() & 0xff; - char c = b2cSB[b1]; - int inSize = 1; - if (c == UNMAPPABLE_DECODING) { - if (src.remaining() < 1) - return crMalformedOrUnderFlow(b1); - int b2 = src.get() & 0xff; - if (b2 < b2Min || b2 > b2Max || - (c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) - return crMalformedOrUnmappable(b1, b2); - inSize++; - } - dst.put(c); - mark += inSize; - } - return src.hasRemaining()? CoderResult.OVERFLOW - : CoderResult.UNDERFLOW; - } finally { - src.position(mark); - } - } - - // Make some protected methods public for use by JISAutoDetect - public CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) { - if (src.hasArray() && dst.hasArray()) - return decodeArrayLoop(src, dst); - else - return decodeBufferLoop(src, dst); - } - - public int decode(byte[] src, int sp, int len, char[] dst) { - int dp = 0; - int sl = sp + len; - char repl = replacement().charAt(0); - while (sp < sl) { - int b1 = src[sp++] & 0xff; - char c = b2cSB[b1]; - if (c == UNMAPPABLE_DECODING) { - if (sp < sl) { - int b2 = src[sp++] & 0xff; - if (b2 < b2Min || b2 > b2Max || - (c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) { - if (b2c[b1] == B2C_UNMAPPABLE || // isNotLeadingByte - b2c[b2] != B2C_UNMAPPABLE || // isLeadingByte - decodeSingle(b2) != UNMAPPABLE_DECODING) { - sp--; - } - } - } - if (c == UNMAPPABLE_DECODING) { - c = repl; - } - } - dst[dp++] = c; - } - return dp; - } - - public void implReset() { - super.implReset(); - } - - public CoderResult implFlush(CharBuffer out) { - return super.implFlush(out); - } - - // decode loops are not using decodeSingle/Double() for performance - // reason. - public char decodeSingle(int b) { - return b2cSB[b]; - } - - public char decodeDouble(int b1, int b2) { - if (b1 < 0 || b1 > b2c.length || - b2 < b2Min || b2 > b2Max) - return UNMAPPABLE_DECODING; - return b2c[b1][b2 - b2Min]; - } - } - - // IBM_EBCDIC_DBCS - public static class Decoder_EBCDIC extends Decoder { - private static final int SBCS = 0; - private static final int DBCS = 1; - private static final int SO = 0x0e; - private static final int SI = 0x0f; - private int currentState; - - Decoder_EBCDIC(Charset cs, - char[][] b2c, char[] b2cSB, int b2Min, int b2Max) { - super(cs, b2c, b2cSB, b2Min, b2Max); - } - - public void implReset() { - currentState = SBCS; - } - - // Check validity of dbcs ebcdic byte pair values - // - // First byte : 0x41 -- 0xFE - // Second byte: 0x41 -- 0xFE - // Doublebyte blank: 0x4040 - // - // The validation implementation in "old" DBCS_IBM_EBCDIC and sun.io - // as - // if ((b1 != 0x40 || b2 != 0x40) && - // (b2 < 0x41 || b2 > 0xfe)) {...} - // is not correct/complete (range check for b1) - // - private static boolean isDoubleByte(int b1, int b2) { - return (0x41 <= b1 && b1 <= 0xfe && 0x41 <= b2 && b2 <= 0xfe) - || (b1 == 0x40 && b2 == 0x40); // DBCS-HOST SPACE - } - - protected CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) { - byte[] sa = src.array(); - int sp = src.arrayOffset() + src.position(); - int sl = src.arrayOffset() + src.limit(); - char[] da = dst.array(); - int dp = dst.arrayOffset() + dst.position(); - int dl = dst.arrayOffset() + dst.limit(); - - try { - // don't check dp/dl together here, it's possible to - // decdoe a SO/SI without space in output buffer. - while (sp < sl) { - int b1 = sa[sp] & 0xff; - int inSize = 1; - if (b1 == SO) { // Shift out - if (currentState != SBCS) - return CoderResult.malformedForLength(1); - else - currentState = DBCS; - } else if (b1 == SI) { - if (currentState != DBCS) - return CoderResult.malformedForLength(1); - else - currentState = SBCS; - } else { - char c = UNMAPPABLE_DECODING; - if (currentState == SBCS) { - c = b2cSB[b1]; - if (c == UNMAPPABLE_DECODING) - return CoderResult.unmappableForLength(1); - } else { - if (sl - sp < 2) - return CoderResult.UNDERFLOW; - int b2 = sa[sp + 1] & 0xff; - if (b2 < b2Min || b2 > b2Max || - (c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) { - if (!isDoubleByte(b1, b2)) - return CoderResult.malformedForLength(2); - return CoderResult.unmappableForLength(2); - } - inSize++; - } - if (dl - dp < 1) - return CoderResult.OVERFLOW; - - da[dp++] = c; - } - sp += inSize; - } - return CoderResult.UNDERFLOW; - } finally { - src.position(sp - src.arrayOffset()); - dst.position(dp - dst.arrayOffset()); - } - } - - protected CoderResult decodeBufferLoop(ByteBuffer src, CharBuffer dst) { - int mark = src.position(); - try { - while (src.hasRemaining()) { - int b1 = src.get() & 0xff; - int inSize = 1; - if (b1 == SO) { // Shift out - if (currentState != SBCS) - return CoderResult.malformedForLength(1); - else - currentState = DBCS; - } else if (b1 == SI) { - if (currentState != DBCS) - return CoderResult.malformedForLength(1); - else - currentState = SBCS; - } else { - char c = UNMAPPABLE_DECODING; - if (currentState == SBCS) { - c = b2cSB[b1]; - if (c == UNMAPPABLE_DECODING) - return CoderResult.unmappableForLength(1); - } else { - if (src.remaining() < 1) - return CoderResult.UNDERFLOW; - int b2 = src.get()&0xff; - if (b2 < b2Min || b2 > b2Max || - (c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) { - if (!isDoubleByte(b1, b2)) - return CoderResult.malformedForLength(2); - return CoderResult.unmappableForLength(2); - } - inSize++; - } - - if (dst.remaining() < 1) - return CoderResult.OVERFLOW; - - dst.put(c); - } - mark += inSize; - } - return CoderResult.UNDERFLOW; - } finally { - src.position(mark); - } - } - - public int decode(byte[] src, int sp, int len, char[] dst) { - int dp = 0; - int sl = sp + len; - currentState = SBCS; - char repl = replacement().charAt(0); - while (sp < sl) { - int b1 = src[sp++] & 0xff; - if (b1 == SO) { // Shift out - if (currentState != SBCS) - dst[dp++] = repl; - else - currentState = DBCS; - } else if (b1 == SI) { - if (currentState != DBCS) - dst[dp++] = repl; - else - currentState = SBCS; - } else { - char c = UNMAPPABLE_DECODING; - if (currentState == SBCS) { - c = b2cSB[b1]; - if (c == UNMAPPABLE_DECODING) - c = repl; - } else { - if (sl == sp) { - c = repl; - } else { - int b2 = src[sp++] & 0xff; - if (b2 < b2Min || b2 > b2Max || - (c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) { - c = repl; - } - } - } - dst[dp++] = c; - } - } - return dp; - } - } - - // DBCS_ONLY - public static class Decoder_DBCSONLY extends Decoder { - static final char[] b2cSB_UNMAPPABLE; - static { - b2cSB_UNMAPPABLE = new char[0x100]; - Arrays.fill(b2cSB_UNMAPPABLE, UNMAPPABLE_DECODING); - } - Decoder_DBCSONLY(Charset cs, char[][] b2c, char[] b2cSB, int b2Min, int b2Max) { - super(cs, 0.5f, 1.0f, b2c, b2cSB_UNMAPPABLE, b2Min, b2Max); - } - } - - // EUC_SIMPLE - // The only thing we need to "override" is to check SS2/SS3 and - // return "malformed" if found - public static class Decoder_EUC_SIM extends Decoder { - private final int SS2 = 0x8E; - private final int SS3 = 0x8F; - - Decoder_EUC_SIM(Charset cs, - char[][] b2c, char[] b2cSB, int b2Min, int b2Max) { - super(cs, b2c, b2cSB, b2Min, b2Max); - } - - // No support provided for G2/G3 for SimpleEUC - protected CoderResult crMalformedOrUnderFlow(int b) { - if (b == SS2 || b == SS3 ) - return CoderResult.malformedForLength(1); - return CoderResult.UNDERFLOW; - } - - protected CoderResult crMalformedOrUnmappable(int b1, int b2) { - if (b1 == SS2 || b1 == SS3 ) - return CoderResult.malformedForLength(1); - return CoderResult.unmappableForLength(2); - } - - public int decode(byte[] src, int sp, int len, char[] dst) { - int dp = 0; - int sl = sp + len; - char repl = replacement().charAt(0); - while (sp < sl) { - int b1 = src[sp++] & 0xff; - char c = b2cSB[b1]; - if (c == UNMAPPABLE_DECODING) { - if (sp < sl) { - int b2 = src[sp++] & 0xff; - if (b2 < b2Min || b2 > b2Max || - (c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) { - if (b1 == SS2 || b1 == SS3) { - sp--; - } - c = repl; - } - } else { - c = repl; - } - } - dst[dp++] = c; - } - return dp; - } - } - - public static class Encoder extends CharsetEncoder - implements ArrayEncoder - { - final int MAX_SINGLEBYTE = 0xff; - private final char[] c2b; - private final char[] c2bIndex; - Surrogate.Parser sgp; - - protected Encoder(Charset cs, char[] c2b, char[] c2bIndex) { - super(cs, 2.0f, 2.0f); - this.c2b = c2b; - this.c2bIndex = c2bIndex; - } - - Encoder(Charset cs, float avg, float max, byte[] repl, char[] c2b, char[] c2bIndex) { - super(cs, avg, max, repl); - this.c2b = c2b; - this.c2bIndex = c2bIndex; - } - - public boolean canEncode(char c) { - return encodeChar(c) != UNMAPPABLE_ENCODING; - } - - Surrogate.Parser sgp() { - if (sgp == null) - sgp = new Surrogate.Parser(); - return sgp; - } - - protected CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) { - char[] sa = src.array(); - int sp = src.arrayOffset() + src.position(); - int sl = src.arrayOffset() + src.limit(); - - byte[] da = dst.array(); - int dp = dst.arrayOffset() + dst.position(); - int dl = dst.arrayOffset() + dst.limit(); - - try { - while (sp < sl) { - char c = sa[sp]; - int bb = encodeChar(c); - if (bb == UNMAPPABLE_ENCODING) { - if (Character.isSurrogate(c)) { - if (sgp().parse(c, sa, sp, sl) < 0) - return sgp.error(); - return sgp.unmappableResult(); - } - return CoderResult.unmappableForLength(1); - } - - if (bb > MAX_SINGLEBYTE) { // DoubleByte - if (dl - dp < 2) - return CoderResult.OVERFLOW; - da[dp++] = (byte)(bb >> 8); - da[dp++] = (byte)bb; - } else { // SingleByte - if (dl - dp < 1) - return CoderResult.OVERFLOW; - da[dp++] = (byte)bb; - } - - sp++; - } - return CoderResult.UNDERFLOW; - } finally { - src.position(sp - src.arrayOffset()); - dst.position(dp - dst.arrayOffset()); - } - } - - protected CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) { - int mark = src.position(); - try { - while (src.hasRemaining()) { - char c = src.get(); - int bb = encodeChar(c); - if (bb == UNMAPPABLE_ENCODING) { - if (Character.isSurrogate(c)) { - if (sgp().parse(c, src) < 0) - return sgp.error(); - return sgp.unmappableResult(); - } - return CoderResult.unmappableForLength(1); - } - if (bb > MAX_SINGLEBYTE) { // DoubleByte - if (dst.remaining() < 2) - return CoderResult.OVERFLOW; - dst.put((byte)(bb >> 8)); - dst.put((byte)(bb)); - } else { - if (dst.remaining() < 1) - return CoderResult.OVERFLOW; - dst.put((byte)bb); - } - mark++; - } - return CoderResult.UNDERFLOW; - } finally { - src.position(mark); - } - } - - protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) { - if (src.hasArray() && dst.hasArray()) - return encodeArrayLoop(src, dst); - else - return encodeBufferLoop(src, dst); - } - - protected byte[] repl = replacement(); - protected void implReplaceWith(byte[] newReplacement) { - repl = newReplacement; - } - - public int encode(char[] src, int sp, int len, byte[] dst) { - int dp = 0; - int sl = sp + len; - int dl = dst.length; - while (sp < sl) { - char c = src[sp++]; - int bb = encodeChar(c); - if (bb == UNMAPPABLE_ENCODING) { - if (Character.isHighSurrogate(c) && sp < sl && - Character.isLowSurrogate(src[sp])) { - sp++; - } - dst[dp++] = repl[0]; - if (repl.length > 1) - dst[dp++] = repl[1]; - continue; - } //else - if (bb > MAX_SINGLEBYTE) { // DoubleByte - dst[dp++] = (byte)(bb >> 8); - dst[dp++] = (byte)bb; - } else { // SingleByte - dst[dp++] = (byte)bb; - } - - } - return dp; - } - - public int encodeChar(char ch) { - return c2b[c2bIndex[ch >> 8] + (ch & 0xff)]; - } - - // init the c2b and c2bIndex tables from b2c. - static void initC2B(String[] b2c, String b2cSB, String b2cNR, String c2bNR, - int b2Min, int b2Max, - char[] c2b, char[] c2bIndex) - { - Arrays.fill(c2b, (char)UNMAPPABLE_ENCODING); - int off = 0x100; - - char[][] b2c_ca = new char[b2c.length][]; - char[] b2cSB_ca = null; - if (b2cSB != null) - b2cSB_ca = b2cSB.toCharArray(); - - for (int i = 0; i < b2c.length; i++) { - if (b2c[i] == null) - continue; - b2c_ca[i] = b2c[i].toCharArray(); - } - - if (b2cNR != null) { - int j = 0; - while (j < b2cNR.length()) { - char b = b2cNR.charAt(j++); - char c = b2cNR.charAt(j++); - if (b < 0x100 && b2cSB_ca != null) { - if (b2cSB_ca[b] == c) - b2cSB_ca[b] = UNMAPPABLE_DECODING; - } else { - if (b2c_ca[b >> 8][(b & 0xff) - b2Min] == c) - b2c_ca[b >> 8][(b & 0xff) - b2Min] = UNMAPPABLE_DECODING; - } - } - } - - if (b2cSB_ca != null) { // SingleByte - for (int b = 0; b < b2cSB_ca.length; b++) { - char c = b2cSB_ca[b]; - if (c == UNMAPPABLE_DECODING) - continue; - int index = c2bIndex[c >> 8]; - if (index == 0) { - index = off; - off += 0x100; - c2bIndex[c >> 8] = (char)index; - } - c2b[index + (c & 0xff)] = (char)b; - } - } - - for (int b1 = 0; b1 < b2c.length; b1++) { // DoubleByte - char[] db = b2c_ca[b1]; - if (db == null) - continue; - for (int b2 = b2Min; b2 <= b2Max; b2++) { - char c = db[b2 - b2Min]; - if (c == UNMAPPABLE_DECODING) - continue; - int index = c2bIndex[c >> 8]; - if (index == 0) { - index = off; - off += 0x100; - c2bIndex[c >> 8] = (char)index; - } - c2b[index + (c & 0xff)] = (char)((b1 << 8) | b2); - } - } - - if (c2bNR != null) { - // add c->b only nr entries - for (int i = 0; i < c2bNR.length(); i += 2) { - char b = c2bNR.charAt(i); - char c = c2bNR.charAt(i + 1); - int index = (c >> 8); - if (c2bIndex[index] == 0) { - c2bIndex[index] = (char)off; - off += 0x100; - } - index = c2bIndex[index] + (c & 0xff); - c2b[index] = b; - } - } - } - } - - public static class Encoder_DBCSONLY extends Encoder { - Encoder_DBCSONLY(Charset cs, byte[] repl, - char[] c2b, char[] c2bIndex) { - super(cs, 2.0f, 2.0f, repl, c2b, c2bIndex); - } - - public int encodeChar(char ch) { - int bb = super.encodeChar(ch); - if (bb <= MAX_SINGLEBYTE) - return UNMAPPABLE_ENCODING; - return bb; - } - } - - - - public static class Encoder_EBCDIC extends Encoder { - static final int SBCS = 0; - static final int DBCS = 1; - static final byte SO = 0x0e; - static final byte SI = 0x0f; - - protected int currentState = SBCS; - - Encoder_EBCDIC(Charset cs, char[] c2b, char[] c2bIndex) { - super(cs, 4.0f, 5.0f, new byte[] {(byte)0x6f}, c2b, c2bIndex); - } - - protected void implReset() { - currentState = SBCS; - } - - protected CoderResult implFlush(ByteBuffer out) { - if (currentState == DBCS) { - if (out.remaining() < 1) - return CoderResult.OVERFLOW; - out.put(SI); - } - implReset(); - return CoderResult.UNDERFLOW; - } - - protected CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) { - char[] sa = src.array(); - int sp = src.arrayOffset() + src.position(); - int sl = src.arrayOffset() + src.limit(); - byte[] da = dst.array(); - int dp = dst.arrayOffset() + dst.position(); - int dl = dst.arrayOffset() + dst.limit(); - - try { - while (sp < sl) { - char c = sa[sp]; - int bb = encodeChar(c); - if (bb == UNMAPPABLE_ENCODING) { - if (Character.isSurrogate(c)) { - if (sgp().parse(c, sa, sp, sl) < 0) - return sgp.error(); - return sgp.unmappableResult(); - } - return CoderResult.unmappableForLength(1); - } - if (bb > MAX_SINGLEBYTE) { // DoubleByte - if (currentState == SBCS) { - if (dl - dp < 1) - return CoderResult.OVERFLOW; - currentState = DBCS; - da[dp++] = SO; - } - if (dl - dp < 2) - return CoderResult.OVERFLOW; - da[dp++] = (byte)(bb >> 8); - da[dp++] = (byte)bb; - } else { // SingleByte - if (currentState == DBCS) { - if (dl - dp < 1) - return CoderResult.OVERFLOW; - currentState = SBCS; - da[dp++] = SI; - } - if (dl - dp < 1) - return CoderResult.OVERFLOW; - da[dp++] = (byte)bb; - - } - sp++; - } - return CoderResult.UNDERFLOW; - } finally { - src.position(sp - src.arrayOffset()); - dst.position(dp - dst.arrayOffset()); - } - } - - protected CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) { - int mark = src.position(); - try { - while (src.hasRemaining()) { - char c = src.get(); - int bb = encodeChar(c); - if (bb == UNMAPPABLE_ENCODING) { - if (Character.isSurrogate(c)) { - if (sgp().parse(c, src) < 0) - return sgp.error(); - return sgp.unmappableResult(); - } - return CoderResult.unmappableForLength(1); - } - if (bb > MAX_SINGLEBYTE) { // DoubleByte - if (currentState == SBCS) { - if (dst.remaining() < 1) - return CoderResult.OVERFLOW; - currentState = DBCS; - dst.put(SO); - } - if (dst.remaining() < 2) - return CoderResult.OVERFLOW; - dst.put((byte)(bb >> 8)); - dst.put((byte)(bb)); - } else { // Single-byte - if (currentState == DBCS) { - if (dst.remaining() < 1) - return CoderResult.OVERFLOW; - currentState = SBCS; - dst.put(SI); - } - if (dst.remaining() < 1) - return CoderResult.OVERFLOW; - dst.put((byte)bb); - } - mark++; - } - return CoderResult.UNDERFLOW; - } finally { - src.position(mark); - } - } - - public int encode(char[] src, int sp, int len, byte[] dst) { - int dp = 0; - int sl = sp + len; - while (sp < sl) { - char c = src[sp++]; - int bb = encodeChar(c); - - if (bb == UNMAPPABLE_ENCODING) { - if (Character.isHighSurrogate(c) && sp < sl && - Character.isLowSurrogate(src[sp])) { - sp++; - } - dst[dp++] = repl[0]; - if (repl.length > 1) - dst[dp++] = repl[1]; - continue; - } //else - if (bb > MAX_SINGLEBYTE) { // DoubleByte - if (currentState == SBCS) { - currentState = DBCS; - dst[dp++] = SO; - } - dst[dp++] = (byte)(bb >> 8); - dst[dp++] = (byte)bb; - } else { // SingleByte - if (currentState == DBCS) { - currentState = SBCS; - dst[dp++] = SI; - } - dst[dp++] = (byte)bb; - } - } - - if (currentState == DBCS) { - currentState = SBCS; - dst[dp++] = SI; - } - return dp; - } - } - - // EUC_SIMPLE - public static class Encoder_EUC_SIM extends Encoder { - Encoder_EUC_SIM(Charset cs, char[] c2b, char[] c2bIndex) { - super(cs, c2b, c2bIndex); - } - } - -} --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/src/java.base/share/classes/sun/nio/cs/DoubleByte.java 2015-02-16 10:41:15.000000000 -0800 @@ -0,0 +1,929 @@ +/* + * Copyright (c) 2009, 2013, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package sun.nio.cs; + +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.CharsetEncoder; +import java.nio.charset.CoderResult; +import java.util.Arrays; +import sun.nio.cs.Surrogate; +import sun.nio.cs.ArrayDecoder; +import sun.nio.cs.ArrayEncoder; +import static sun.nio.cs.CharsetMapping.*; + +/* + * Four types of "DoubleByte" charsets are implemented in this class + * (1)DoubleByte + * The "mostly widely used" multibyte charset, a combination of + * a singlebyte character set (usually the ASCII charset) and a + * doublebyte character set. The codepoint values of singlebyte + * and doublebyte don't overlap. Microsoft's multibyte charsets + * and IBM's "DBCS_ASCII" charsets, such as IBM1381, 942, 943, + * 948, 949 and 950 are such charsets. + * + * (2)DoubleByte_EBCDIC + * IBM EBCDIC Mix multibyte charset. Use SO and SI to shift (switch) + * in and out between the singlebyte character set and doublebyte + * character set. + * + * (3)DoubleByte_SIMPLE_EUC + * It's a "simple" form of EUC encoding scheme, only have the + * singlebyte character set G0 and one doublebyte character set + * G1 are defined, G2 (with SS2) and G3 (with SS3) are not used. + * So it is actually the same as the "typical" type (1) mentioned + * above, except it return "malformed" for the SS2 and SS3 when + * decoding. + * + * (4)DoubleByte ONLY + * A "pure" doublebyte only character set. From implementation + * point of view, this is the type (1) with "decodeSingle" always + * returns unmappable. + * + * For simplicity, all implementations share the same decoding and + * encoding data structure. + * + * Decoding: + * + * char[][] b2c; + * char[] b2cSB; + * int b2Min, b2Max + * + * public char decodeSingle(int b) { + * return b2cSB.[b]; + * } + * + * public char decodeDouble(int b1, int b2) { + * if (b2 < b2Min || b2 > b2Max) + * return UNMAPPABLE_DECODING; + * return b2c[b1][b2 - b2Min]; + * } + * + * (1)b2Min, b2Max are the corresponding min and max value of the + * low-half of the double-byte. + * (2)The high 8-bit/b1 of the double-byte are used to indexed into + * b2c array. + * + * Encoding: + * + * char[] c2b; + * char[] c2bIndex; + * + * public int encodeChar(char ch) { + * return c2b[c2bIndex[ch >> 8] + (ch & 0xff)]; + * } + * + */ + +public class DoubleByte { + + public final static char[] B2C_UNMAPPABLE; + static { + B2C_UNMAPPABLE = new char[0x100]; + Arrays.fill(B2C_UNMAPPABLE, UNMAPPABLE_DECODING); + } + + public static class Decoder extends CharsetDecoder + implements DelegatableDecoder, ArrayDecoder + { + final char[][] b2c; + final char[] b2cSB; + final int b2Min; + final int b2Max; + + // for SimpleEUC override + protected CoderResult crMalformedOrUnderFlow(int b) { + return CoderResult.UNDERFLOW; + } + + protected CoderResult crMalformedOrUnmappable(int b1, int b2) { + if (b2c[b1] == B2C_UNMAPPABLE || // isNotLeadingByte(b1) + b2c[b2] != B2C_UNMAPPABLE || // isLeadingByte(b2) + decodeSingle(b2) != UNMAPPABLE_DECODING) { // isSingle(b2) + return CoderResult.malformedForLength(1); + } + return CoderResult.unmappableForLength(2); + } + + public Decoder(Charset cs, float avgcpb, float maxcpb, + char[][] b2c, char[] b2cSB, + int b2Min, int b2Max) { + super(cs, avgcpb, maxcpb); + this.b2c = b2c; + this.b2cSB = b2cSB; + this.b2Min = b2Min; + this.b2Max = b2Max; + } + + public Decoder(Charset cs, char[][] b2c, char[] b2cSB, int b2Min, int b2Max) { + this(cs, 0.5f, 1.0f, b2c, b2cSB, b2Min, b2Max); + } + + protected CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) { + byte[] sa = src.array(); + int sp = src.arrayOffset() + src.position(); + int sl = src.arrayOffset() + src.limit(); + + char[] da = dst.array(); + int dp = dst.arrayOffset() + dst.position(); + int dl = dst.arrayOffset() + dst.limit(); + + try { + while (sp < sl && dp < dl) { + // inline the decodeSingle/Double() for better performance + int inSize = 1; + int b1 = sa[sp] & 0xff; + char c = b2cSB[b1]; + if (c == UNMAPPABLE_DECODING) { + if (sl - sp < 2) + return crMalformedOrUnderFlow(b1); + int b2 = sa[sp + 1] & 0xff; + if (b2 < b2Min || b2 > b2Max || + (c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) { + return crMalformedOrUnmappable(b1, b2); + } + inSize++; + } + da[dp++] = c; + sp += inSize; + } + return (sp >= sl) ? CoderResult.UNDERFLOW + : CoderResult.OVERFLOW; + } finally { + src.position(sp - src.arrayOffset()); + dst.position(dp - dst.arrayOffset()); + } + } + + protected CoderResult decodeBufferLoop(ByteBuffer src, CharBuffer dst) { + int mark = src.position(); + try { + + while (src.hasRemaining() && dst.hasRemaining()) { + int b1 = src.get() & 0xff; + char c = b2cSB[b1]; + int inSize = 1; + if (c == UNMAPPABLE_DECODING) { + if (src.remaining() < 1) + return crMalformedOrUnderFlow(b1); + int b2 = src.get() & 0xff; + if (b2 < b2Min || b2 > b2Max || + (c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) + return crMalformedOrUnmappable(b1, b2); + inSize++; + } + dst.put(c); + mark += inSize; + } + return src.hasRemaining()? CoderResult.OVERFLOW + : CoderResult.UNDERFLOW; + } finally { + src.position(mark); + } + } + + // Make some protected methods public for use by JISAutoDetect + public CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) { + if (src.hasArray() && dst.hasArray()) + return decodeArrayLoop(src, dst); + else + return decodeBufferLoop(src, dst); + } + + public int decode(byte[] src, int sp, int len, char[] dst) { + int dp = 0; + int sl = sp + len; + char repl = replacement().charAt(0); + while (sp < sl) { + int b1 = src[sp++] & 0xff; + char c = b2cSB[b1]; + if (c == UNMAPPABLE_DECODING) { + if (sp < sl) { + int b2 = src[sp++] & 0xff; + if (b2 < b2Min || b2 > b2Max || + (c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) { + if (b2c[b1] == B2C_UNMAPPABLE || // isNotLeadingByte + b2c[b2] != B2C_UNMAPPABLE || // isLeadingByte + decodeSingle(b2) != UNMAPPABLE_DECODING) { + sp--; + } + } + } + if (c == UNMAPPABLE_DECODING) { + c = repl; + } + } + dst[dp++] = c; + } + return dp; + } + + public void implReset() { + super.implReset(); + } + + public CoderResult implFlush(CharBuffer out) { + return super.implFlush(out); + } + + // decode loops are not using decodeSingle/Double() for performance + // reason. + public char decodeSingle(int b) { + return b2cSB[b]; + } + + public char decodeDouble(int b1, int b2) { + if (b1 < 0 || b1 > b2c.length || + b2 < b2Min || b2 > b2Max) + return UNMAPPABLE_DECODING; + return b2c[b1][b2 - b2Min]; + } + } + + // IBM_EBCDIC_DBCS + public static class Decoder_EBCDIC extends Decoder { + private static final int SBCS = 0; + private static final int DBCS = 1; + private static final int SO = 0x0e; + private static final int SI = 0x0f; + private int currentState; + + public Decoder_EBCDIC(Charset cs, + char[][] b2c, char[] b2cSB, int b2Min, int b2Max) { + super(cs, b2c, b2cSB, b2Min, b2Max); + } + + public void implReset() { + currentState = SBCS; + } + + // Check validity of dbcs ebcdic byte pair values + // + // First byte : 0x41 -- 0xFE + // Second byte: 0x41 -- 0xFE + // Doublebyte blank: 0x4040 + // + // The validation implementation in "old" DBCS_IBM_EBCDIC and sun.io + // as + // if ((b1 != 0x40 || b2 != 0x40) && + // (b2 < 0x41 || b2 > 0xfe)) {...} + // is not correct/complete (range check for b1) + // + private static boolean isDoubleByte(int b1, int b2) { + return (0x41 <= b1 && b1 <= 0xfe && 0x41 <= b2 && b2 <= 0xfe) + || (b1 == 0x40 && b2 == 0x40); // DBCS-HOST SPACE + } + + protected CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) { + byte[] sa = src.array(); + int sp = src.arrayOffset() + src.position(); + int sl = src.arrayOffset() + src.limit(); + char[] da = dst.array(); + int dp = dst.arrayOffset() + dst.position(); + int dl = dst.arrayOffset() + dst.limit(); + + try { + // don't check dp/dl together here, it's possible to + // decdoe a SO/SI without space in output buffer. + while (sp < sl) { + int b1 = sa[sp] & 0xff; + int inSize = 1; + if (b1 == SO) { // Shift out + if (currentState != SBCS) + return CoderResult.malformedForLength(1); + else + currentState = DBCS; + } else if (b1 == SI) { + if (currentState != DBCS) + return CoderResult.malformedForLength(1); + else + currentState = SBCS; + } else { + char c = UNMAPPABLE_DECODING; + if (currentState == SBCS) { + c = b2cSB[b1]; + if (c == UNMAPPABLE_DECODING) + return CoderResult.unmappableForLength(1); + } else { + if (sl - sp < 2) + return CoderResult.UNDERFLOW; + int b2 = sa[sp + 1] & 0xff; + if (b2 < b2Min || b2 > b2Max || + (c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) { + if (!isDoubleByte(b1, b2)) + return CoderResult.malformedForLength(2); + return CoderResult.unmappableForLength(2); + } + inSize++; + } + if (dl - dp < 1) + return CoderResult.OVERFLOW; + + da[dp++] = c; + } + sp += inSize; + } + return CoderResult.UNDERFLOW; + } finally { + src.position(sp - src.arrayOffset()); + dst.position(dp - dst.arrayOffset()); + } + } + + protected CoderResult decodeBufferLoop(ByteBuffer src, CharBuffer dst) { + int mark = src.position(); + try { + while (src.hasRemaining()) { + int b1 = src.get() & 0xff; + int inSize = 1; + if (b1 == SO) { // Shift out + if (currentState != SBCS) + return CoderResult.malformedForLength(1); + else + currentState = DBCS; + } else if (b1 == SI) { + if (currentState != DBCS) + return CoderResult.malformedForLength(1); + else + currentState = SBCS; + } else { + char c = UNMAPPABLE_DECODING; + if (currentState == SBCS) { + c = b2cSB[b1]; + if (c == UNMAPPABLE_DECODING) + return CoderResult.unmappableForLength(1); + } else { + if (src.remaining() < 1) + return CoderResult.UNDERFLOW; + int b2 = src.get()&0xff; + if (b2 < b2Min || b2 > b2Max || + (c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) { + if (!isDoubleByte(b1, b2)) + return CoderResult.malformedForLength(2); + return CoderResult.unmappableForLength(2); + } + inSize++; + } + + if (dst.remaining() < 1) + return CoderResult.OVERFLOW; + + dst.put(c); + } + mark += inSize; + } + return CoderResult.UNDERFLOW; + } finally { + src.position(mark); + } + } + + public int decode(byte[] src, int sp, int len, char[] dst) { + int dp = 0; + int sl = sp + len; + currentState = SBCS; + char repl = replacement().charAt(0); + while (sp < sl) { + int b1 = src[sp++] & 0xff; + if (b1 == SO) { // Shift out + if (currentState != SBCS) + dst[dp++] = repl; + else + currentState = DBCS; + } else if (b1 == SI) { + if (currentState != DBCS) + dst[dp++] = repl; + else + currentState = SBCS; + } else { + char c = UNMAPPABLE_DECODING; + if (currentState == SBCS) { + c = b2cSB[b1]; + if (c == UNMAPPABLE_DECODING) + c = repl; + } else { + if (sl == sp) { + c = repl; + } else { + int b2 = src[sp++] & 0xff; + if (b2 < b2Min || b2 > b2Max || + (c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) { + c = repl; + } + } + } + dst[dp++] = c; + } + } + return dp; + } + } + + // DBCS_ONLY + public static class Decoder_DBCSONLY extends Decoder { + static final char[] b2cSB_UNMAPPABLE; + static { + b2cSB_UNMAPPABLE = new char[0x100]; + Arrays.fill(b2cSB_UNMAPPABLE, UNMAPPABLE_DECODING); + } + public Decoder_DBCSONLY(Charset cs, char[][] b2c, char[] b2cSB, int b2Min, int b2Max) { + super(cs, 0.5f, 1.0f, b2c, b2cSB_UNMAPPABLE, b2Min, b2Max); + } + } + + // EUC_SIMPLE + // The only thing we need to "override" is to check SS2/SS3 and + // return "malformed" if found + public static class Decoder_EUC_SIM extends Decoder { + private final int SS2 = 0x8E; + private final int SS3 = 0x8F; + + public Decoder_EUC_SIM(Charset cs, + char[][] b2c, char[] b2cSB, int b2Min, int b2Max) { + super(cs, b2c, b2cSB, b2Min, b2Max); + } + + // No support provided for G2/G3 for SimpleEUC + protected CoderResult crMalformedOrUnderFlow(int b) { + if (b == SS2 || b == SS3 ) + return CoderResult.malformedForLength(1); + return CoderResult.UNDERFLOW; + } + + protected CoderResult crMalformedOrUnmappable(int b1, int b2) { + if (b1 == SS2 || b1 == SS3 ) + return CoderResult.malformedForLength(1); + return CoderResult.unmappableForLength(2); + } + + public int decode(byte[] src, int sp, int len, char[] dst) { + int dp = 0; + int sl = sp + len; + char repl = replacement().charAt(0); + while (sp < sl) { + int b1 = src[sp++] & 0xff; + char c = b2cSB[b1]; + if (c == UNMAPPABLE_DECODING) { + if (sp < sl) { + int b2 = src[sp++] & 0xff; + if (b2 < b2Min || b2 > b2Max || + (c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) { + if (b1 == SS2 || b1 == SS3) { + sp--; + } + c = repl; + } + } else { + c = repl; + } + } + dst[dp++] = c; + } + return dp; + } + } + + public static class Encoder extends CharsetEncoder + implements ArrayEncoder + { + protected final int MAX_SINGLEBYTE = 0xff; + private final char[] c2b; + private final char[] c2bIndex; + protected Surrogate.Parser sgp; + + public Encoder(Charset cs, char[] c2b, char[] c2bIndex) { + super(cs, 2.0f, 2.0f); + this.c2b = c2b; + this.c2bIndex = c2bIndex; + } + + public Encoder(Charset cs, float avg, float max, byte[] repl, char[] c2b, char[] c2bIndex) { + super(cs, avg, max, repl); + this.c2b = c2b; + this.c2bIndex = c2bIndex; + } + + public boolean canEncode(char c) { + return encodeChar(c) != UNMAPPABLE_ENCODING; + } + + protected Surrogate.Parser sgp() { + if (sgp == null) + sgp = new Surrogate.Parser(); + return sgp; + } + + protected CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) { + char[] sa = src.array(); + int sp = src.arrayOffset() + src.position(); + int sl = src.arrayOffset() + src.limit(); + + byte[] da = dst.array(); + int dp = dst.arrayOffset() + dst.position(); + int dl = dst.arrayOffset() + dst.limit(); + + try { + while (sp < sl) { + char c = sa[sp]; + int bb = encodeChar(c); + if (bb == UNMAPPABLE_ENCODING) { + if (Character.isSurrogate(c)) { + if (sgp().parse(c, sa, sp, sl) < 0) + return sgp.error(); + return sgp.unmappableResult(); + } + return CoderResult.unmappableForLength(1); + } + + if (bb > MAX_SINGLEBYTE) { // DoubleByte + if (dl - dp < 2) + return CoderResult.OVERFLOW; + da[dp++] = (byte)(bb >> 8); + da[dp++] = (byte)bb; + } else { // SingleByte + if (dl - dp < 1) + return CoderResult.OVERFLOW; + da[dp++] = (byte)bb; + } + + sp++; + } + return CoderResult.UNDERFLOW; + } finally { + src.position(sp - src.arrayOffset()); + dst.position(dp - dst.arrayOffset()); + } + } + + protected CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) { + int mark = src.position(); + try { + while (src.hasRemaining()) { + char c = src.get(); + int bb = encodeChar(c); + if (bb == UNMAPPABLE_ENCODING) { + if (Character.isSurrogate(c)) { + if (sgp().parse(c, src) < 0) + return sgp.error(); + return sgp.unmappableResult(); + } + return CoderResult.unmappableForLength(1); + } + if (bb > MAX_SINGLEBYTE) { // DoubleByte + if (dst.remaining() < 2) + return CoderResult.OVERFLOW; + dst.put((byte)(bb >> 8)); + dst.put((byte)(bb)); + } else { + if (dst.remaining() < 1) + return CoderResult.OVERFLOW; + dst.put((byte)bb); + } + mark++; + } + return CoderResult.UNDERFLOW; + } finally { + src.position(mark); + } + } + + protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) { + if (src.hasArray() && dst.hasArray()) + return encodeArrayLoop(src, dst); + else + return encodeBufferLoop(src, dst); + } + + protected byte[] repl = replacement(); + protected void implReplaceWith(byte[] newReplacement) { + repl = newReplacement; + } + + public int encode(char[] src, int sp, int len, byte[] dst) { + int dp = 0; + int sl = sp + len; + int dl = dst.length; + while (sp < sl) { + char c = src[sp++]; + int bb = encodeChar(c); + if (bb == UNMAPPABLE_ENCODING) { + if (Character.isHighSurrogate(c) && sp < sl && + Character.isLowSurrogate(src[sp])) { + sp++; + } + dst[dp++] = repl[0]; + if (repl.length > 1) + dst[dp++] = repl[1]; + continue; + } //else + if (bb > MAX_SINGLEBYTE) { // DoubleByte + dst[dp++] = (byte)(bb >> 8); + dst[dp++] = (byte)bb; + } else { // SingleByte + dst[dp++] = (byte)bb; + } + + } + return dp; + } + + public int encodeChar(char ch) { + return c2b[c2bIndex[ch >> 8] + (ch & 0xff)]; + } + + // init the c2b and c2bIndex tables from b2c. + public static void initC2B(String[] b2c, String b2cSB, String b2cNR, String c2bNR, + int b2Min, int b2Max, + char[] c2b, char[] c2bIndex) + { + Arrays.fill(c2b, (char)UNMAPPABLE_ENCODING); + int off = 0x100; + + char[][] b2c_ca = new char[b2c.length][]; + char[] b2cSB_ca = null; + if (b2cSB != null) + b2cSB_ca = b2cSB.toCharArray(); + + for (int i = 0; i < b2c.length; i++) { + if (b2c[i] == null) + continue; + b2c_ca[i] = b2c[i].toCharArray(); + } + + if (b2cNR != null) { + int j = 0; + while (j < b2cNR.length()) { + char b = b2cNR.charAt(j++); + char c = b2cNR.charAt(j++); + if (b < 0x100 && b2cSB_ca != null) { + if (b2cSB_ca[b] == c) + b2cSB_ca[b] = UNMAPPABLE_DECODING; + } else { + if (b2c_ca[b >> 8][(b & 0xff) - b2Min] == c) + b2c_ca[b >> 8][(b & 0xff) - b2Min] = UNMAPPABLE_DECODING; + } + } + } + + if (b2cSB_ca != null) { // SingleByte + for (int b = 0; b < b2cSB_ca.length; b++) { + char c = b2cSB_ca[b]; + if (c == UNMAPPABLE_DECODING) + continue; + int index = c2bIndex[c >> 8]; + if (index == 0) { + index = off; + off += 0x100; + c2bIndex[c >> 8] = (char)index; + } + c2b[index + (c & 0xff)] = (char)b; + } + } + + for (int b1 = 0; b1 < b2c.length; b1++) { // DoubleByte + char[] db = b2c_ca[b1]; + if (db == null) + continue; + for (int b2 = b2Min; b2 <= b2Max; b2++) { + char c = db[b2 - b2Min]; + if (c == UNMAPPABLE_DECODING) + continue; + int index = c2bIndex[c >> 8]; + if (index == 0) { + index = off; + off += 0x100; + c2bIndex[c >> 8] = (char)index; + } + c2b[index + (c & 0xff)] = (char)((b1 << 8) | b2); + } + } + + if (c2bNR != null) { + // add c->b only nr entries + for (int i = 0; i < c2bNR.length(); i += 2) { + char b = c2bNR.charAt(i); + char c = c2bNR.charAt(i + 1); + int index = (c >> 8); + if (c2bIndex[index] == 0) { + c2bIndex[index] = (char)off; + off += 0x100; + } + index = c2bIndex[index] + (c & 0xff); + c2b[index] = b; + } + } + } + } + + public static class Encoder_DBCSONLY extends Encoder { + public Encoder_DBCSONLY(Charset cs, byte[] repl, + char[] c2b, char[] c2bIndex) { + super(cs, 2.0f, 2.0f, repl, c2b, c2bIndex); + } + + public int encodeChar(char ch) { + int bb = super.encodeChar(ch); + if (bb <= MAX_SINGLEBYTE) + return UNMAPPABLE_ENCODING; + return bb; + } + } + + + + public static class Encoder_EBCDIC extends Encoder { + static final int SBCS = 0; + static final int DBCS = 1; + static final byte SO = 0x0e; + static final byte SI = 0x0f; + + protected int currentState = SBCS; + + public Encoder_EBCDIC(Charset cs, char[] c2b, char[] c2bIndex) { + super(cs, 4.0f, 5.0f, new byte[] {(byte)0x6f}, c2b, c2bIndex); + } + + protected void implReset() { + currentState = SBCS; + } + + protected CoderResult implFlush(ByteBuffer out) { + if (currentState == DBCS) { + if (out.remaining() < 1) + return CoderResult.OVERFLOW; + out.put(SI); + } + implReset(); + return CoderResult.UNDERFLOW; + } + + protected CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) { + char[] sa = src.array(); + int sp = src.arrayOffset() + src.position(); + int sl = src.arrayOffset() + src.limit(); + byte[] da = dst.array(); + int dp = dst.arrayOffset() + dst.position(); + int dl = dst.arrayOffset() + dst.limit(); + + try { + while (sp < sl) { + char c = sa[sp]; + int bb = encodeChar(c); + if (bb == UNMAPPABLE_ENCODING) { + if (Character.isSurrogate(c)) { + if (sgp().parse(c, sa, sp, sl) < 0) + return sgp.error(); + return sgp.unmappableResult(); + } + return CoderResult.unmappableForLength(1); + } + if (bb > MAX_SINGLEBYTE) { // DoubleByte + if (currentState == SBCS) { + if (dl - dp < 1) + return CoderResult.OVERFLOW; + currentState = DBCS; + da[dp++] = SO; + } + if (dl - dp < 2) + return CoderResult.OVERFLOW; + da[dp++] = (byte)(bb >> 8); + da[dp++] = (byte)bb; + } else { // SingleByte + if (currentState == DBCS) { + if (dl - dp < 1) + return CoderResult.OVERFLOW; + currentState = SBCS; + da[dp++] = SI; + } + if (dl - dp < 1) + return CoderResult.OVERFLOW; + da[dp++] = (byte)bb; + + } + sp++; + } + return CoderResult.UNDERFLOW; + } finally { + src.position(sp - src.arrayOffset()); + dst.position(dp - dst.arrayOffset()); + } + } + + protected CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) { + int mark = src.position(); + try { + while (src.hasRemaining()) { + char c = src.get(); + int bb = encodeChar(c); + if (bb == UNMAPPABLE_ENCODING) { + if (Character.isSurrogate(c)) { + if (sgp().parse(c, src) < 0) + return sgp.error(); + return sgp.unmappableResult(); + } + return CoderResult.unmappableForLength(1); + } + if (bb > MAX_SINGLEBYTE) { // DoubleByte + if (currentState == SBCS) { + if (dst.remaining() < 1) + return CoderResult.OVERFLOW; + currentState = DBCS; + dst.put(SO); + } + if (dst.remaining() < 2) + return CoderResult.OVERFLOW; + dst.put((byte)(bb >> 8)); + dst.put((byte)(bb)); + } else { // Single-byte + if (currentState == DBCS) { + if (dst.remaining() < 1) + return CoderResult.OVERFLOW; + currentState = SBCS; + dst.put(SI); + } + if (dst.remaining() < 1) + return CoderResult.OVERFLOW; + dst.put((byte)bb); + } + mark++; + } + return CoderResult.UNDERFLOW; + } finally { + src.position(mark); + } + } + + public int encode(char[] src, int sp, int len, byte[] dst) { + int dp = 0; + int sl = sp + len; + while (sp < sl) { + char c = src[sp++]; + int bb = encodeChar(c); + + if (bb == UNMAPPABLE_ENCODING) { + if (Character.isHighSurrogate(c) && sp < sl && + Character.isLowSurrogate(src[sp])) { + sp++; + } + dst[dp++] = repl[0]; + if (repl.length > 1) + dst[dp++] = repl[1]; + continue; + } //else + if (bb > MAX_SINGLEBYTE) { // DoubleByte + if (currentState == SBCS) { + currentState = DBCS; + dst[dp++] = SO; + } + dst[dp++] = (byte)(bb >> 8); + dst[dp++] = (byte)bb; + } else { // SingleByte + if (currentState == DBCS) { + currentState = SBCS; + dst[dp++] = SI; + } + dst[dp++] = (byte)bb; + } + } + + if (currentState == DBCS) { + currentState = SBCS; + dst[dp++] = SI; + } + return dp; + } + } + + // EUC_SIMPLE + public static class Encoder_EUC_SIM extends Encoder { + public Encoder_EUC_SIM(Charset cs, char[] c2b, char[] c2bIndex) { + super(cs, c2b, c2bIndex); + } + } + +} --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/HKSCS.java 2015-02-16 10:41:16.000000000 -0800 +++ /dev/null 2014-05-19 13:38:05.886368312 -0700 @@ -1,433 +0,0 @@ -/* - * Copyright (c) 2010, 2013, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -package sun.nio.cs.ext; - -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.nio.charset.CharsetEncoder; -import java.nio.charset.CoderResult; -import java.util.Arrays; -import sun.nio.cs.Surrogate; -import static sun.nio.cs.CharsetMapping.*; - -public class HKSCS { - - public static class Decoder extends DoubleByte.Decoder { - static int b2Min = 0x40; - static int b2Max = 0xfe; - - private char[][] b2cBmp; - private char[][] b2cSupp; - private DoubleByte.Decoder big5Dec; - - protected Decoder(Charset cs, - DoubleByte.Decoder big5Dec, - char[][] b2cBmp, char[][] b2cSupp) - { - // super(cs, 0.5f, 1.0f); - // need to extends DoubleByte.Decoder so the - // sun.io can use it. this implementation - super(cs, 0.5f, 1.0f, null, null, 0, 0); - this.big5Dec = big5Dec; - this.b2cBmp = b2cBmp; - this.b2cSupp = b2cSupp; - } - - public char decodeSingle(int b) { - return big5Dec.decodeSingle(b); - } - - public char decodeBig5(int b1, int b2) { - return big5Dec.decodeDouble(b1, b2); - } - - public char decodeDouble(int b1, int b2) { - return b2cBmp[b1][b2 - b2Min]; - } - - public char decodeDoubleEx(int b1, int b2) { - /* if the b2cSupp is null, the subclass need - to override the methold - if (b2cSupp == null) - return UNMAPPABLE_DECODING; - */ - return b2cSupp[b1][b2 - b2Min]; - } - - protected CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) { - byte[] sa = src.array(); - int sp = src.arrayOffset() + src.position(); - int sl = src.arrayOffset() + src.limit(); - - char[] da = dst.array(); - int dp = dst.arrayOffset() + dst.position(); - int dl = dst.arrayOffset() + dst.limit(); - - try { - while (sp < sl) { - int b1 = sa[sp] & 0xff; - char c = decodeSingle(b1); - int inSize = 1, outSize = 1; - char[] cc = null; - if (c == UNMAPPABLE_DECODING) { - if (sl - sp < 2) - return CoderResult.UNDERFLOW; - int b2 = sa[sp + 1] & 0xff; - inSize++; - if (b2 < b2Min || b2 > b2Max) - return CoderResult.unmappableForLength(2); - c = decodeDouble(b1, b2); //bmp - if (c == UNMAPPABLE_DECODING) { - c = decodeDoubleEx(b1, b2); //supp - if (c == UNMAPPABLE_DECODING) { - c = decodeBig5(b1, b2); //big5 - if (c == UNMAPPABLE_DECODING) - return CoderResult.unmappableForLength(2); - } else { - // supplementary character in u+2xxxx area - outSize = 2; - } - } - } - if (dl - dp < outSize) - return CoderResult.OVERFLOW; - if (outSize == 2) { - // supplementary characters - da[dp++] = Surrogate.high(0x20000 + c); - da[dp++] = Surrogate.low(0x20000 + c); - } else { - da[dp++] = c; - } - sp += inSize; - } - return CoderResult.UNDERFLOW; - } finally { - src.position(sp - src.arrayOffset()); - dst.position(dp - dst.arrayOffset()); - } - } - - protected CoderResult decodeBufferLoop(ByteBuffer src, CharBuffer dst) { - int mark = src.position(); - try { - while (src.hasRemaining()) { - char[] cc = null; - int b1 = src.get() & 0xff; - int inSize = 1, outSize = 1; - char c = decodeSingle(b1); - if (c == UNMAPPABLE_DECODING) { - if (src.remaining() < 1) - return CoderResult.UNDERFLOW; - int b2 = src.get() & 0xff; - inSize++; - if (b2 < b2Min || b2 > b2Max) - return CoderResult.unmappableForLength(2); - c = decodeDouble(b1, b2); //bmp - if (c == UNMAPPABLE_DECODING) { - c = decodeDoubleEx(b1, b2); //supp - if (c == UNMAPPABLE_DECODING) { - c = decodeBig5(b1, b2); //big5 - if (c == UNMAPPABLE_DECODING) - return CoderResult.unmappableForLength(2); - } else { - outSize = 2; - } - } - } - if (dst.remaining() < outSize) - return CoderResult.OVERFLOW; - if (outSize == 2) { - dst.put(Surrogate.high(0x20000 + c)); - dst.put(Surrogate.low(0x20000 + c)); - } else { - dst.put(c); - } - mark += inSize; - } - return CoderResult.UNDERFLOW; - } finally { - src.position(mark); - } - } - - public int decode(byte[] src, int sp, int len, char[] dst) { - int dp = 0; - int sl = sp + len; - char repl = replacement().charAt(0); - while (sp < sl) { - int b1 = src[sp++] & 0xff; - char c = decodeSingle(b1); - if (c == UNMAPPABLE_DECODING) { - if (sl == sp) { - c = repl; - } else { - int b2 = src[sp++] & 0xff; - if (b2 < b2Min || b2 > b2Max) { - c = repl; - } else if ((c = decodeDouble(b1, b2)) == UNMAPPABLE_DECODING) { - c = decodeDoubleEx(b1, b2); //supp - if (c == UNMAPPABLE_DECODING) { - c = decodeBig5(b1, b2); //big5 - if (c == UNMAPPABLE_DECODING) - c = repl; - } else { - // supplementary character in u+2xxxx area - dst[dp++] = Surrogate.high(0x20000 + c); - dst[dp++] = Surrogate.low(0x20000 + c); - continue; - } - } - } - } - dst[dp++] = c; - } - return dp; - } - - public CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) { - if (src.hasArray() && dst.hasArray()) - return decodeArrayLoop(src, dst); - else - return decodeBufferLoop(src, dst); - } - - static void initb2c(char[][]b2c, String[] b2cStr) - { - for (int i = 0; i < b2cStr.length; i++) { - if (b2cStr[i] == null) - b2c[i] = DoubleByte.B2C_UNMAPPABLE; - else - b2c[i] = b2cStr[i].toCharArray(); - } - } - - } - - public static class Encoder extends DoubleByte.Encoder { - private DoubleByte.Encoder big5Enc; - private char[][] c2bBmp; - private char[][] c2bSupp; - - protected Encoder(Charset cs, - DoubleByte.Encoder big5Enc, - char[][] c2bBmp, - char[][] c2bSupp) - { - super(cs, null, null); - this.big5Enc = big5Enc; - this.c2bBmp = c2bBmp; - this.c2bSupp = c2bSupp; - } - - public int encodeBig5(char ch) { - return big5Enc.encodeChar(ch); - } - - public int encodeChar(char ch) { - int bb = c2bBmp[ch >> 8][ch & 0xff]; - if (bb == UNMAPPABLE_ENCODING) - return encodeBig5(ch); - return bb; - } - - public int encodeSupp(int cp) { - if ((cp & 0xf0000) != 0x20000) - return UNMAPPABLE_ENCODING; - return c2bSupp[(cp >> 8) & 0xff][cp & 0xff]; - } - - public boolean canEncode(char c) { - return encodeChar(c) != UNMAPPABLE_ENCODING; - } - - protected CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) { - char[] sa = src.array(); - int sp = src.arrayOffset() + src.position(); - int sl = src.arrayOffset() + src.limit(); - - byte[] da = dst.array(); - int dp = dst.arrayOffset() + dst.position(); - int dl = dst.arrayOffset() + dst.limit(); - - try { - while (sp < sl) { - char c = sa[sp]; - int inSize = 1; - int bb = encodeChar(c); - if (bb == UNMAPPABLE_ENCODING) { - if (Character.isSurrogate(c)) { - int cp; - if ((cp = sgp().parse(c, sa, sp, sl)) < 0) - return sgp.error(); - bb = encodeSupp(cp); - if (bb == UNMAPPABLE_ENCODING) - return CoderResult.unmappableForLength(2); - inSize = 2; - } else { - return CoderResult.unmappableForLength(1); - } - } - if (bb > MAX_SINGLEBYTE) { // DoubleByte - if (dl - dp < 2) - return CoderResult.OVERFLOW; - da[dp++] = (byte)(bb >> 8); - da[dp++] = (byte)bb; - } else { // SingleByte - if (dl - dp < 1) - return CoderResult.OVERFLOW; - da[dp++] = (byte)bb; - } - sp += inSize; - } - return CoderResult.UNDERFLOW; - } finally { - src.position(sp - src.arrayOffset()); - dst.position(dp - dst.arrayOffset()); - } - } - - protected CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) { - int mark = src.position(); - try { - while (src.hasRemaining()) { - int inSize = 1; - char c = src.get(); - int bb = encodeChar(c); - if (bb == UNMAPPABLE_ENCODING) { - if (Character.isSurrogate(c)) { - int cp; - if ((cp = sgp().parse(c, src)) < 0) - return sgp.error(); - bb = encodeSupp(cp); - if (bb == UNMAPPABLE_ENCODING) - return CoderResult.unmappableForLength(2); - inSize = 2; - } else { - return CoderResult.unmappableForLength(1); - } - } - if (bb > MAX_SINGLEBYTE) { // DoubleByte - if (dst.remaining() < 2) - return CoderResult.OVERFLOW; - dst.put((byte)(bb >> 8)); - dst.put((byte)(bb)); - } else { - if (dst.remaining() < 1) - return CoderResult.OVERFLOW; - dst.put((byte)bb); - } - mark += inSize; - } - return CoderResult.UNDERFLOW; - } finally { - src.position(mark); - } - } - - protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) { - if (src.hasArray() && dst.hasArray()) - return encodeArrayLoop(src, dst); - else - return encodeBufferLoop(src, dst); - } - - private byte[] repl = replacement(); - protected void implReplaceWith(byte[] newReplacement) { - repl = newReplacement; - } - - public int encode(char[] src, int sp, int len, byte[] dst) { - int dp = 0; - int sl = sp + len; - while (sp < sl) { - char c = src[sp++]; - int bb = encodeChar(c); - if (bb == UNMAPPABLE_ENCODING) { - if (!Character.isHighSurrogate(c) || sp == sl || - !Character.isLowSurrogate(src[sp]) || - (bb = encodeSupp(Character.toCodePoint(c, src[sp++]))) - == UNMAPPABLE_ENCODING) { - dst[dp++] = repl[0]; - if (repl.length > 1) - dst[dp++] = repl[1]; - continue; - } - sp++; - } - if (bb > MAX_SINGLEBYTE) { // DoubleByte - dst[dp++] = (byte)(bb >> 8); - dst[dp++] = (byte)bb; - } else { // SingleByte - dst[dp++] = (byte)bb; - } - } - return dp; - } - - - static char[] C2B_UNMAPPABLE = new char[0x100]; - static { - Arrays.fill(C2B_UNMAPPABLE, (char)UNMAPPABLE_ENCODING); - } - - static void initc2b(char[][] c2b, String[] b2cStr, String pua) { - // init c2b/c2bSupp from b2cStr and supp - int b2Min = 0x40; - Arrays.fill(c2b, C2B_UNMAPPABLE); - for (int b1 = 0; b1 < 0x100; b1++) { - String s = b2cStr[b1]; - if (s == null) - continue; - for (int i = 0; i < s.length(); i++) { - char c = s.charAt(i); - int hi = c >> 8; - if (c2b[hi] == C2B_UNMAPPABLE) { - c2b[hi] = new char[0x100]; - Arrays.fill(c2b[hi], (char)UNMAPPABLE_ENCODING); - } - c2b[hi][c & 0xff] = (char)((b1 << 8) | (i + b2Min)); - } - } - if (pua != null) { // add the compatibility pua entries - char c = '\ue000'; //first pua character - for (int i = 0; i < pua.length(); i++) { - char bb = pua.charAt(i); - if (bb != UNMAPPABLE_DECODING) { - int hi = c >> 8; - if (c2b[hi] == C2B_UNMAPPABLE) { - c2b[hi] = new char[0x100]; - Arrays.fill(c2b[hi], (char)UNMAPPABLE_ENCODING); - } - c2b[hi][c & 0xff] = bb; - } - c++; - } - } - } - } -} --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/src/java.base/share/classes/sun/nio/cs/HKSCS.java 2015-02-16 10:41:16.000000000 -0800 @@ -0,0 +1,434 @@ +/* + * Copyright (c) 2010, 2013, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package sun.nio.cs; + +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.CharsetEncoder; +import java.nio.charset.CoderResult; +import java.util.Arrays; +import sun.nio.cs.DoubleByte; +import sun.nio.cs.Surrogate; +import static sun.nio.cs.CharsetMapping.*; + +public class HKSCS { + + public static class Decoder extends DoubleByte.Decoder { + static int b2Min = 0x40; + static int b2Max = 0xfe; + + private char[][] b2cBmp; + private char[][] b2cSupp; + private DoubleByte.Decoder big5Dec; + + protected Decoder(Charset cs, + DoubleByte.Decoder big5Dec, + char[][] b2cBmp, char[][] b2cSupp) + { + // super(cs, 0.5f, 1.0f); + // need to extends DoubleByte.Decoder so the + // sun.io can use it. this implementation + super(cs, 0.5f, 1.0f, null, null, 0, 0); + this.big5Dec = big5Dec; + this.b2cBmp = b2cBmp; + this.b2cSupp = b2cSupp; + } + + public char decodeSingle(int b) { + return big5Dec.decodeSingle(b); + } + + public char decodeBig5(int b1, int b2) { + return big5Dec.decodeDouble(b1, b2); + } + + public char decodeDouble(int b1, int b2) { + return b2cBmp[b1][b2 - b2Min]; + } + + public char decodeDoubleEx(int b1, int b2) { + /* if the b2cSupp is null, the subclass need + to override the methold + if (b2cSupp == null) + return UNMAPPABLE_DECODING; + */ + return b2cSupp[b1][b2 - b2Min]; + } + + protected CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) { + byte[] sa = src.array(); + int sp = src.arrayOffset() + src.position(); + int sl = src.arrayOffset() + src.limit(); + + char[] da = dst.array(); + int dp = dst.arrayOffset() + dst.position(); + int dl = dst.arrayOffset() + dst.limit(); + + try { + while (sp < sl) { + int b1 = sa[sp] & 0xff; + char c = decodeSingle(b1); + int inSize = 1, outSize = 1; + char[] cc = null; + if (c == UNMAPPABLE_DECODING) { + if (sl - sp < 2) + return CoderResult.UNDERFLOW; + int b2 = sa[sp + 1] & 0xff; + inSize++; + if (b2 < b2Min || b2 > b2Max) + return CoderResult.unmappableForLength(2); + c = decodeDouble(b1, b2); //bmp + if (c == UNMAPPABLE_DECODING) { + c = decodeDoubleEx(b1, b2); //supp + if (c == UNMAPPABLE_DECODING) { + c = decodeBig5(b1, b2); //big5 + if (c == UNMAPPABLE_DECODING) + return CoderResult.unmappableForLength(2); + } else { + // supplementary character in u+2xxxx area + outSize = 2; + } + } + } + if (dl - dp < outSize) + return CoderResult.OVERFLOW; + if (outSize == 2) { + // supplementary characters + da[dp++] = Surrogate.high(0x20000 + c); + da[dp++] = Surrogate.low(0x20000 + c); + } else { + da[dp++] = c; + } + sp += inSize; + } + return CoderResult.UNDERFLOW; + } finally { + src.position(sp - src.arrayOffset()); + dst.position(dp - dst.arrayOffset()); + } + } + + protected CoderResult decodeBufferLoop(ByteBuffer src, CharBuffer dst) { + int mark = src.position(); + try { + while (src.hasRemaining()) { + char[] cc = null; + int b1 = src.get() & 0xff; + int inSize = 1, outSize = 1; + char c = decodeSingle(b1); + if (c == UNMAPPABLE_DECODING) { + if (src.remaining() < 1) + return CoderResult.UNDERFLOW; + int b2 = src.get() & 0xff; + inSize++; + if (b2 < b2Min || b2 > b2Max) + return CoderResult.unmappableForLength(2); + c = decodeDouble(b1, b2); //bmp + if (c == UNMAPPABLE_DECODING) { + c = decodeDoubleEx(b1, b2); //supp + if (c == UNMAPPABLE_DECODING) { + c = decodeBig5(b1, b2); //big5 + if (c == UNMAPPABLE_DECODING) + return CoderResult.unmappableForLength(2); + } else { + outSize = 2; + } + } + } + if (dst.remaining() < outSize) + return CoderResult.OVERFLOW; + if (outSize == 2) { + dst.put(Surrogate.high(0x20000 + c)); + dst.put(Surrogate.low(0x20000 + c)); + } else { + dst.put(c); + } + mark += inSize; + } + return CoderResult.UNDERFLOW; + } finally { + src.position(mark); + } + } + + public int decode(byte[] src, int sp, int len, char[] dst) { + int dp = 0; + int sl = sp + len; + char repl = replacement().charAt(0); + while (sp < sl) { + int b1 = src[sp++] & 0xff; + char c = decodeSingle(b1); + if (c == UNMAPPABLE_DECODING) { + if (sl == sp) { + c = repl; + } else { + int b2 = src[sp++] & 0xff; + if (b2 < b2Min || b2 > b2Max) { + c = repl; + } else if ((c = decodeDouble(b1, b2)) == UNMAPPABLE_DECODING) { + c = decodeDoubleEx(b1, b2); //supp + if (c == UNMAPPABLE_DECODING) { + c = decodeBig5(b1, b2); //big5 + if (c == UNMAPPABLE_DECODING) + c = repl; + } else { + // supplementary character in u+2xxxx area + dst[dp++] = Surrogate.high(0x20000 + c); + dst[dp++] = Surrogate.low(0x20000 + c); + continue; + } + } + } + } + dst[dp++] = c; + } + return dp; + } + + public CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) { + if (src.hasArray() && dst.hasArray()) + return decodeArrayLoop(src, dst); + else + return decodeBufferLoop(src, dst); + } + + public static void initb2c(char[][]b2c, String[] b2cStr) + { + for (int i = 0; i < b2cStr.length; i++) { + if (b2cStr[i] == null) + b2c[i] = DoubleByte.B2C_UNMAPPABLE; + else + b2c[i] = b2cStr[i].toCharArray(); + } + } + + } + + public static class Encoder extends DoubleByte.Encoder { + private DoubleByte.Encoder big5Enc; + private char[][] c2bBmp; + private char[][] c2bSupp; + + protected Encoder(Charset cs, + DoubleByte.Encoder big5Enc, + char[][] c2bBmp, + char[][] c2bSupp) + { + super(cs, null, null); + this.big5Enc = big5Enc; + this.c2bBmp = c2bBmp; + this.c2bSupp = c2bSupp; + } + + public int encodeBig5(char ch) { + return big5Enc.encodeChar(ch); + } + + public int encodeChar(char ch) { + int bb = c2bBmp[ch >> 8][ch & 0xff]; + if (bb == UNMAPPABLE_ENCODING) + return encodeBig5(ch); + return bb; + } + + public int encodeSupp(int cp) { + if ((cp & 0xf0000) != 0x20000) + return UNMAPPABLE_ENCODING; + return c2bSupp[(cp >> 8) & 0xff][cp & 0xff]; + } + + public boolean canEncode(char c) { + return encodeChar(c) != UNMAPPABLE_ENCODING; + } + + protected CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) { + char[] sa = src.array(); + int sp = src.arrayOffset() + src.position(); + int sl = src.arrayOffset() + src.limit(); + + byte[] da = dst.array(); + int dp = dst.arrayOffset() + dst.position(); + int dl = dst.arrayOffset() + dst.limit(); + + try { + while (sp < sl) { + char c = sa[sp]; + int inSize = 1; + int bb = encodeChar(c); + if (bb == UNMAPPABLE_ENCODING) { + if (Character.isSurrogate(c)) { + int cp; + if ((cp = sgp().parse(c, sa, sp, sl)) < 0) + return sgp.error(); + bb = encodeSupp(cp); + if (bb == UNMAPPABLE_ENCODING) + return CoderResult.unmappableForLength(2); + inSize = 2; + } else { + return CoderResult.unmappableForLength(1); + } + } + if (bb > MAX_SINGLEBYTE) { // DoubleByte + if (dl - dp < 2) + return CoderResult.OVERFLOW; + da[dp++] = (byte)(bb >> 8); + da[dp++] = (byte)bb; + } else { // SingleByte + if (dl - dp < 1) + return CoderResult.OVERFLOW; + da[dp++] = (byte)bb; + } + sp += inSize; + } + return CoderResult.UNDERFLOW; + } finally { + src.position(sp - src.arrayOffset()); + dst.position(dp - dst.arrayOffset()); + } + } + + protected CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) { + int mark = src.position(); + try { + while (src.hasRemaining()) { + int inSize = 1; + char c = src.get(); + int bb = encodeChar(c); + if (bb == UNMAPPABLE_ENCODING) { + if (Character.isSurrogate(c)) { + int cp; + if ((cp = sgp().parse(c, src)) < 0) + return sgp.error(); + bb = encodeSupp(cp); + if (bb == UNMAPPABLE_ENCODING) + return CoderResult.unmappableForLength(2); + inSize = 2; + } else { + return CoderResult.unmappableForLength(1); + } + } + if (bb > MAX_SINGLEBYTE) { // DoubleByte + if (dst.remaining() < 2) + return CoderResult.OVERFLOW; + dst.put((byte)(bb >> 8)); + dst.put((byte)(bb)); + } else { + if (dst.remaining() < 1) + return CoderResult.OVERFLOW; + dst.put((byte)bb); + } + mark += inSize; + } + return CoderResult.UNDERFLOW; + } finally { + src.position(mark); + } + } + + protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) { + if (src.hasArray() && dst.hasArray()) + return encodeArrayLoop(src, dst); + else + return encodeBufferLoop(src, dst); + } + + private byte[] repl = replacement(); + protected void implReplaceWith(byte[] newReplacement) { + repl = newReplacement; + } + + public int encode(char[] src, int sp, int len, byte[] dst) { + int dp = 0; + int sl = sp + len; + while (sp < sl) { + char c = src[sp++]; + int bb = encodeChar(c); + if (bb == UNMAPPABLE_ENCODING) { + if (!Character.isHighSurrogate(c) || sp == sl || + !Character.isLowSurrogate(src[sp]) || + (bb = encodeSupp(Character.toCodePoint(c, src[sp++]))) + == UNMAPPABLE_ENCODING) { + dst[dp++] = repl[0]; + if (repl.length > 1) + dst[dp++] = repl[1]; + continue; + } + sp++; + } + if (bb > MAX_SINGLEBYTE) { // DoubleByte + dst[dp++] = (byte)(bb >> 8); + dst[dp++] = (byte)bb; + } else { // SingleByte + dst[dp++] = (byte)bb; + } + } + return dp; + } + + + static char[] C2B_UNMAPPABLE = new char[0x100]; + static { + Arrays.fill(C2B_UNMAPPABLE, (char)UNMAPPABLE_ENCODING); + } + + public static void initc2b(char[][] c2b, String[] b2cStr, String pua) { + // init c2b/c2bSupp from b2cStr and supp + int b2Min = 0x40; + Arrays.fill(c2b, C2B_UNMAPPABLE); + for (int b1 = 0; b1 < 0x100; b1++) { + String s = b2cStr[b1]; + if (s == null) + continue; + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + int hi = c >> 8; + if (c2b[hi] == C2B_UNMAPPABLE) { + c2b[hi] = new char[0x100]; + Arrays.fill(c2b[hi], (char)UNMAPPABLE_ENCODING); + } + c2b[hi][c & 0xff] = (char)((b1 << 8) | (i + b2Min)); + } + } + if (pua != null) { // add the compatibility pua entries + char c = '\ue000'; //first pua character + for (int i = 0; i < pua.length(); i++) { + char bb = pua.charAt(i); + if (bb != UNMAPPABLE_DECODING) { + int hi = c >> 8; + if (c2b[hi] == C2B_UNMAPPABLE) { + c2b[hi] = new char[0x100]; + Arrays.fill(c2b[hi], (char)UNMAPPABLE_ENCODING); + } + c2b[hi][c & 0xff] = bb; + } + c++; + } + } + } + } +} --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/ExtendedCharsets.java 2015-02-16 10:41:18.000000000 -0800 +++ /dev/null 2014-05-19 13:38:05.886368312 -0700 @@ -1,1326 +0,0 @@ -/* - * Copyright (c) 2002, 2013, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -package sun.nio.cs.ext; - -import java.lang.ref.SoftReference; -import java.nio.charset.Charset; -import java.nio.charset.spi.CharsetProvider; -import sun.nio.cs.AbstractCharsetProvider; -import java.security.AccessController; -import java.security.PrivilegedAction; - -/** - * Provider for extended charsets. - */ - -public class ExtendedCharsets - extends AbstractCharsetProvider -{ - - static volatile ExtendedCharsets instance = null; - - public ExtendedCharsets() { - - super("sun.nio.cs.ext"); // identify provider pkg name. - - // Traditional Chinese - - charset("Big5", "Big5", - new String[] { - // IANA aliases - "csBig5" - }); - - charset("x-MS950-HKSCS-XP", "MS950_HKSCS_XP", - new String[] { - "MS950_HKSCS_XP" // JDK historical; - }); - - charset("x-MS950-HKSCS", "MS950_HKSCS", - new String[] { - // IANA aliases - "MS950_HKSCS" // JDK historical; - }); - - charset("x-windows-950", "MS950", - new String[] { - "ms950", // JDK historical - "windows-950" - }); - - charset("x-windows-874", "MS874", - new String[] { - "ms874", // JDK historical - "ms-874", - "windows-874" }); - - charset("x-EUC-TW", "EUC_TW", - new String[] { - "euc_tw", // JDK historical - "euctw", - "cns11643", - "EUC-TW" - }); - - charset("Big5-HKSCS", "Big5_HKSCS", - new String[] { - "Big5_HKSCS", // JDK historical - "big5hk", - "big5-hkscs", - "big5hkscs" // Linux alias - }); - - charset("x-Big5-HKSCS-2001", "Big5_HKSCS_2001", - new String[] { - "Big5_HKSCS_2001", - "big5hk-2001", - "big5-hkscs-2001", - "big5-hkscs:unicode3.0", - "big5hkscs-2001", - }); - - charset("x-Big5-Solaris", "Big5_Solaris", - new String[] { - "Big5_Solaris", // JDK historical - }); - - // Simplified Chinese - charset("GBK", "GBK", - new String[] { - "windows-936", - "CP936" - }); - - charset("GB18030", "GB18030", - new String[] { - "gb18030-2000" - }); - - charset("GB2312", "EUC_CN", - new String[] { - // IANA aliases - "gb2312", - "gb2312-80", - "gb2312-1980", - "euc-cn", - "euccn", - "x-EUC-CN", // 1.4 compatibility - "EUC_CN" //JDK historical - }); - - charset("x-mswin-936", "MS936", - new String[] { - "ms936", // historical - // IANA aliases - "ms_936" - }); - - // The definition of this charset may be overridden by the init method, - // below, if the sun.nio.cs.map property is defined. - // - charset("Shift_JIS", "SJIS", - new String[] { - // IANA aliases - "sjis", // historical - "shift_jis", - "shift-jis", - "ms_kanji", - "x-sjis", - "csShiftJIS" - }); - - // The definition of this charset may be overridden by the init method, - // below, if the sun.nio.cs.map property is defined. - // - charset("windows-31j", "MS932", - new String[] { - "MS932", // JDK historical - "windows-932", - "csWindows31J" - }); - - charset("JIS_X0201", "JIS_X_0201", - new String[] { - "JIS0201", // JDK historical - // IANA aliases - "JIS_X0201", - "X0201", - "csHalfWidthKatakana" - }); - - charset("x-JIS0208", "JIS_X_0208", - new String[] { - "JIS0208", // JDK historical - // IANA aliases - "JIS_C6226-1983", - "iso-ir-87", - "x0208", - "JIS_X0208-1983", - "csISO87JISX0208" - }); - - charset("JIS_X0212-1990", "JIS_X_0212", - new String[] { - "JIS0212", // JDK historical - // IANA aliases - "jis_x0212-1990", - "x0212", - "iso-ir-159", - "csISO159JISX02121990" - }); - - charset("x-SJIS_0213", "SJIS_0213", - new String[] { - "sjis-0213", - "sjis_0213", - "sjis:2004", - "sjis_0213:2004", - "shift_jis_0213:2004", - "shift_jis:2004" - }); - - charset("x-MS932_0213", "MS932_0213", - new String[] { - "MS932-0213", - "MS932_0213", - "MS932:2004", - "windows-932-0213", - "windows-932:2004" - }); - - charset("EUC-JP", "EUC_JP", - new String[] { - "euc_jp", // JDK historical - // IANA aliases - "eucjis", - "eucjp", - "Extended_UNIX_Code_Packed_Format_for_Japanese", - "csEUCPkdFmtjapanese", - "x-euc-jp", - "x-eucjp" - }); - - charset("x-euc-jp-linux", "EUC_JP_LINUX", - new String[] { - "euc_jp_linux", // JDK historical - "euc-jp-linux" - }); - - charset("x-eucjp-open", "EUC_JP_Open", - new String[] { - "EUC_JP_Solaris", // JDK historical - "eucJP-open" - }); - - charset("x-PCK", "PCK", - new String[] { - // IANA aliases - "pck" // historical - }); - - charset("ISO-2022-JP", "ISO2022_JP", - new String[] { - // IANA aliases - "iso2022jp", // historical - "jis", - "csISO2022JP", - "jis_encoding", - "csjisencoding" - }); - - charset("ISO-2022-JP-2", "ISO2022_JP_2", - new String[] { - // IANA aliases - "csISO2022JP2", - "iso2022jp2" - }); - - charset("x-windows-50221", "MS50221", - new String[] { - "ms50221", // historical - "cp50221", - }); - - charset("x-windows-50220", "MS50220", - new String[] { - "ms50220", // historical - "cp50220", - }); - - charset("x-windows-iso2022jp", "MSISO2022JP", - new String[] { - "windows-iso2022jp", // historical - }); - - charset("x-JISAutoDetect", "JISAutoDetect", - new String[] { - "JISAutoDetect" // historical - }); - - // Korean - charset("EUC-KR", "EUC_KR", - new String[] { - "euc_kr", // JDK historical - // IANA aliases - "ksc5601", - "euckr", - "ks_c_5601-1987", - "ksc5601-1987", - "ksc5601_1987", - "ksc_5601", - "csEUCKR", - "5601" - }); - - charset("x-windows-949", "MS949", - new String[] { - "ms949", // JDK historical - "windows949", - "windows-949", - // IANA aliases - "ms_949" - }); - - charset("x-Johab", "Johab", - new String[] { - "ksc5601-1992", - "ksc5601_1992", - "ms1361", - "johab" // JDK historical - }); - - charset("ISO-2022-KR", "ISO2022_KR", - new String[] { - "ISO2022KR", // JDK historical - "csISO2022KR" - }); - - charset("ISO-2022-CN", "ISO2022_CN", - new String[] { - "ISO2022CN", // JDK historical - "csISO2022CN" - }); - - charset("x-ISO-2022-CN-CNS", "ISO2022_CN_CNS", - new String[] { - "ISO2022CN_CNS", // JDK historical - "ISO-2022-CN-CNS" - }); - - charset("x-ISO-2022-CN-GB", "ISO2022_CN_GB", - new String[] { - "ISO2022CN_GB", // JDK historical - "ISO-2022-CN-GB" - }); - - charset("x-ISCII91", "ISCII91", - new String[] { - "iscii", - "ST_SEV_358-88", - "iso-ir-153", - "csISO153GOST1976874", - "ISCII91" // JDK historical - }); - - charset("ISO-8859-3", "ISO_8859_3", - new String[] { - "iso8859_3", // JDK historical - "8859_3", - "ISO_8859-3:1988", - "iso-ir-109", - "ISO_8859-3", - "ISO8859-3", - "latin3", - "l3", - "ibm913", - "ibm-913", - "cp913", - "913", - "csISOLatin3" - }); - - charset("ISO-8859-6", "ISO_8859_6", - new String[] { - "iso8859_6", // JDK historical - "8859_6", - "iso-ir-127", - "ISO_8859-6", - "ISO_8859-6:1987", - "ISO8859-6", - "ECMA-114", - "ASMO-708", - "arabic", - "ibm1089", - "ibm-1089", - "cp1089", - "1089", - "csISOLatinArabic" - }); - - charset("ISO-8859-8", "ISO_8859_8", - new String[] { - "iso8859_8", // JDK historical - "8859_8", - "iso-ir-138", - "ISO_8859-8", - "ISO_8859-8:1988", - "ISO8859-8", - "cp916", - "916", - "ibm916", - "ibm-916", - "hebrew", - "csISOLatinHebrew" - }); - - charset("x-ISO-8859-11", "ISO_8859_11", - new String[] { - "iso-8859-11", - "iso8859_11" - }); - - charset("TIS-620", "TIS_620", - new String[] { - "tis620", // JDK historical - "tis620.2533" - }); - - // Various Microsoft Windows international codepages - - charset("windows-1255", "MS1255", - new String[] { - "cp1255" // JDK historical - }); - - charset("windows-1256", "MS1256", - new String[] { - "cp1256" // JDK historical - }); - - charset("windows-1258", "MS1258", - new String[] { - "cp1258" // JDK historical - }); - - // IBM & PC/MSDOS encodings - - charset("x-IBM942", "IBM942", - new String[] { - "cp942", // JDK historical - "ibm942", - "ibm-942", - "942" - }); - - charset("x-IBM942C", "IBM942C", - new String[] { - "cp942C", // JDK historical - "ibm942C", - "ibm-942C", - "942C" - }); - - charset("x-IBM943", "IBM943", - new String[] { - "cp943", // JDK historical - "ibm943", - "ibm-943", - "943" - }); - - charset("x-IBM943C", "IBM943C", - new String[] { - "cp943C", // JDK historical - "ibm943C", - "ibm-943C", - "943C" - }); - - charset("x-IBM948", "IBM948", - new String[] { - "cp948", // JDK historical - "ibm948", - "ibm-948", - "948" - }); - - charset("x-IBM950", "IBM950", - new String[] { - "cp950", // JDK historical - "ibm950", - "ibm-950", - "950" - }); - - charset("x-IBM930", "IBM930", - new String[] { - "cp930", // JDK historical - "ibm930", - "ibm-930", - "930" - }); - - charset("x-IBM935", "IBM935", - new String[] { - "cp935", // JDK historical - "ibm935", - "ibm-935", - "935" - }); - - charset("x-IBM937", "IBM937", - new String[] { - "cp937", // JDK historical - "ibm937", - "ibm-937", - "937" - }); - - charset("x-IBM856", "IBM856", - new String[] { - "cp856", // JDK historical - "ibm-856", - "ibm856", - "856" - }); - - charset("IBM860", "IBM860", - new String[] { - "cp860", // JDK historical - "ibm860", - "ibm-860", - "860", - "csIBM860" - }); - charset("IBM861", "IBM861", - new String[] { - "cp861", // JDK historical - "ibm861", - "ibm-861", - "861", - "csIBM861", - "cp-is" - }); - - charset("IBM863", "IBM863", - new String[] { - "cp863", // JDK historical - "ibm863", - "ibm-863", - "863", - "csIBM863" - }); - - charset("IBM864", "IBM864", - new String[] { - "cp864", // JDK historical - "ibm864", - "ibm-864", - "864", - "csIBM864" - }); - - charset("IBM865", "IBM865", - new String[] { - "cp865", // JDK historical - "ibm865", - "ibm-865", - "865", - "csIBM865" - }); - - charset("IBM868", "IBM868", - new String[] { - "cp868", // JDK historical - "ibm868", - "ibm-868", - "868", - "cp-ar", - "csIBM868" - }); - - charset("IBM869", "IBM869", - new String[] { - "cp869", // JDK historical - "ibm869", - "ibm-869", - "869", - "cp-gr", - "csIBM869" - }); - - charset("x-IBM921", "IBM921", - new String[] { - "cp921", // JDK historical - "ibm921", - "ibm-921", - "921" - }); - - charset("x-IBM1006", "IBM1006", - new String[] { - "cp1006", // JDK historical - "ibm1006", - "ibm-1006", - "1006" - }); - - charset("x-IBM1046", "IBM1046", - new String[] { - "cp1046", // JDK historical - "ibm1046", - "ibm-1046", - "1046" - }); - - charset("IBM1047", "IBM1047", - new String[] { - "cp1047", // JDK historical - "ibm-1047", - "1047" - }); - - charset("x-IBM1098", "IBM1098", - new String[] { - "cp1098", // JDK historical - "ibm1098", - "ibm-1098", - "1098", - }); - - charset("IBM037", "IBM037", - new String[] { - "cp037", // JDK historical - "ibm037", - "ebcdic-cp-us", - "ebcdic-cp-ca", - "ebcdic-cp-wt", - "ebcdic-cp-nl", - "csIBM037", - "cs-ebcdic-cp-us", - "cs-ebcdic-cp-ca", - "cs-ebcdic-cp-wt", - "cs-ebcdic-cp-nl", - "ibm-037", - "ibm-37", - "cpibm37", - "037" - }); - - charset("x-IBM1025", "IBM1025", - new String[] { - "cp1025", // JDK historical - "ibm1025", - "ibm-1025", - "1025" - }); - - charset("IBM1026", "IBM1026", - new String[] { - "cp1026", // JDK historical - "ibm1026", - "ibm-1026", - "1026" - }); - - charset("x-IBM1112", "IBM1112", - new String[] { - "cp1112", // JDK historical - "ibm1112", - "ibm-1112", - "1112" - }); - - charset("x-IBM1122", "IBM1122", - new String[] { - "cp1122", // JDK historical - "ibm1122", - "ibm-1122", - "1122" - }); - - charset("x-IBM1123", "IBM1123", - new String[] { - "cp1123", // JDK historical - "ibm1123", - "ibm-1123", - "1123" - }); - - charset("x-IBM1124", "IBM1124", - new String[] { - "cp1124", // JDK historical - "ibm1124", - "ibm-1124", - "1124" - }); - - charset("x-IBM1364", "IBM1364", - new String[] { - "cp1364", - "ibm1364", - "ibm-1364", - "1364" - }); - - charset("IBM273", "IBM273", - new String[] { - "cp273", // JDK historical - "ibm273", - "ibm-273", - "273" - }); - - charset("IBM277", "IBM277", - new String[] { - "cp277", // JDK historical - "ibm277", - "ibm-277", - "277" - }); - - charset("IBM278", "IBM278", - new String[] { - "cp278", // JDK historical - "ibm278", - "ibm-278", - "278", - "ebcdic-sv", - "ebcdic-cp-se", - "csIBM278" - }); - - charset("IBM280", "IBM280", - new String[] { - "cp280", // JDK historical - "ibm280", - "ibm-280", - "280" - }); - - charset("IBM284", "IBM284", - new String[] { - "cp284", // JDK historical - "ibm284", - "ibm-284", - "284", - "csIBM284", - "cpibm284" - }); - - charset("IBM285", "IBM285", - new String[] { - "cp285", // JDK historical - "ibm285", - "ibm-285", - "285", - "ebcdic-cp-gb", - "ebcdic-gb", - "csIBM285", - "cpibm285" - }); - - charset("IBM297", "IBM297", - new String[] { - "cp297", // JDK historical - "ibm297", - "ibm-297", - "297", - "ebcdic-cp-fr", - "cpibm297", - "csIBM297", - }); - - charset("IBM420", "IBM420", - new String[] { - "cp420", // JDK historical - "ibm420", - "ibm-420", - "ebcdic-cp-ar1", - "420", - "csIBM420" - }); - - charset("IBM424", "IBM424", - new String[] { - "cp424", // JDK historical - "ibm424", - "ibm-424", - "424", - "ebcdic-cp-he", - "csIBM424" - }); - - charset("IBM500", "IBM500", - new String[] { - "cp500", // JDK historical - "ibm500", - "ibm-500", - "500", - "ebcdic-cp-ch", - "ebcdic-cp-bh", - "csIBM500" - }); - - charset("x-IBM833", "IBM833", - new String[] { - "cp833", - "ibm833", - "ibm-833" - }); - - //EBCDIC DBCS-only Korean - charset("x-IBM834", "IBM834", - new String[] { - "cp834", - "ibm834", - "834", - "ibm-834" - }); - - - charset("IBM-Thai", "IBM838", - new String[] { - "cp838", // JDK historical - "ibm838", - "ibm-838", - "838" - }); - - charset("IBM870", "IBM870", - new String[] { - "cp870", // JDK historical - "ibm870", - "ibm-870", - "870", - "ebcdic-cp-roece", - "ebcdic-cp-yu", - "csIBM870" - }); - - charset("IBM871", "IBM871", - new String[] { - "cp871", // JDK historical - "ibm871", - "ibm-871", - "871", - "ebcdic-cp-is", - "csIBM871" - }); - - charset("x-IBM875", "IBM875", - new String[] { - "cp875", // JDK historical - "ibm875", - "ibm-875", - "875" - }); - - charset("IBM918", "IBM918", - new String[] { - "cp918", // JDK historical - "ibm-918", - "918", - "ebcdic-cp-ar2" - }); - - charset("x-IBM922", "IBM922", - new String[] { - "cp922", // JDK historical - "ibm922", - "ibm-922", - "922" - }); - - charset("x-IBM1097", "IBM1097", - new String[] { - "cp1097", // JDK historical - "ibm1097", - "ibm-1097", - "1097" - }); - - charset("x-IBM949", "IBM949", - new String[] { - "cp949", // JDK historical - "ibm949", - "ibm-949", - "949" - }); - - charset("x-IBM949C", "IBM949C", - new String[] { - "cp949C", // JDK historical - "ibm949C", - "ibm-949C", - "949C" - }); - - charset("x-IBM939", "IBM939", - new String[] { - "cp939", // JDK historical - "ibm939", - "ibm-939", - "939" - }); - - charset("x-IBM933", "IBM933", - new String[] { - "cp933", // JDK historical - "ibm933", - "ibm-933", - "933" - }); - - charset("x-IBM1381", "IBM1381", - new String[] { - "cp1381", // JDK historical - "ibm1381", - "ibm-1381", - "1381" - }); - - charset("x-IBM1383", "IBM1383", - new String[] { - "cp1383", // JDK historical - "ibm1383", - "ibm-1383", - "1383" - }); - - charset("x-IBM970", "IBM970", - new String[] { - "cp970", // JDK historical - "ibm970", - "ibm-970", - "ibm-eucKR", - "970" - }); - - charset("x-IBM964", "IBM964", - new String[] { - "cp964", // JDK historical - "ibm964", - "ibm-964", - "964" - }); - - charset("x-IBM33722", "IBM33722", - new String[] { - "cp33722", // JDK historical - "ibm33722", - "ibm-33722", - "ibm-5050", // from IBM alias list - "ibm-33722_vascii_vpua", // from IBM alias list - "33722" - }); - - charset("IBM01140", "IBM1140", - new String[] { - "cp1140", // JDK historical - "ccsid01140", - "cp01140", - "1140", - "ebcdic-us-037+euro" - }); - - charset("IBM01141", "IBM1141", - new String[] { - "cp1141", // JDK historical - "ccsid01141", - "cp01141", - "1141", - "ebcdic-de-273+euro" - }); - - charset("IBM01142", "IBM1142", - new String[] { - "cp1142", // JDK historical - "ccsid01142", - "cp01142", - "1142", - "ebcdic-no-277+euro", - "ebcdic-dk-277+euro" - }); - - charset("IBM01143", "IBM1143", - new String[] { - "cp1143", // JDK historical - "ccsid01143", - "cp01143", - "1143", - "ebcdic-fi-278+euro", - "ebcdic-se-278+euro" - }); - - charset("IBM01144", "IBM1144", - new String[] { - "cp1144", // JDK historical - "ccsid01144", - "cp01144", - "1144", - "ebcdic-it-280+euro" - }); - - charset("IBM01145", "IBM1145", - new String[] { - "cp1145", // JDK historical - "ccsid01145", - "cp01145", - "1145", - "ebcdic-es-284+euro" - }); - - charset("IBM01146", "IBM1146", - new String[] { - "cp1146", // JDK historical - "ccsid01146", - "cp01146", - "1146", - "ebcdic-gb-285+euro" - }); - - charset("IBM01147", "IBM1147", - new String[] { - "cp1147", // JDK historical - "ccsid01147", - "cp01147", - "1147", - "ebcdic-fr-277+euro" - }); - - charset("IBM01148", "IBM1148", - new String[] { - "cp1148", // JDK historical - "ccsid01148", - "cp01148", - "1148", - "ebcdic-international-500+euro" - }); - - charset("IBM01149", "IBM1149", - new String[] { - "cp1149", // JDK historical - "ccsid01149", - "cp01149", - "1149", - "ebcdic-s-871+euro" - }); - - charset("IBM290", "IBM290", - new String[] { - "cp290", - "ibm290", - "ibm-290", - "csIBM290", - "EBCDIC-JP-kana", - "290" - }); - - charset("x-IBM300", "IBM300", - new String[] { - "cp300", - "ibm300", - "ibm-300", - "300" - }); - - // Macintosh MacOS/Apple char encodingd - - - charset("x-MacRoman", "MacRoman", - new String[] { - "MacRoman" // JDK historical - }); - - charset("x-MacCentralEurope", "MacCentralEurope", - new String[] { - "MacCentralEurope" // JDK historical - }); - - charset("x-MacCroatian", "MacCroatian", - new String[] { - "MacCroatian" // JDK historical - }); - - - charset("x-MacGreek", "MacGreek", - new String[] { - "MacGreek" // JDK historical - }); - - charset("x-MacCyrillic", "MacCyrillic", - new String[] { - "MacCyrillic" // JDK historical - }); - - charset("x-MacUkraine", "MacUkraine", - new String[] { - "MacUkraine" // JDK historical - }); - - charset("x-MacTurkish", "MacTurkish", - new String[] { - "MacTurkish" // JDK historical - }); - - charset("x-MacArabic", "MacArabic", - new String[] { - "MacArabic" // JDK historical - }); - - charset("x-MacHebrew", "MacHebrew", - new String[] { - "MacHebrew" // JDK historical - }); - - charset("x-MacIceland", "MacIceland", - new String[] { - "MacIceland" // JDK historical - }); - - charset("x-MacRomania", "MacRomania", - new String[] { - "MacRomania" // JDK historical - }); - - charset("x-MacThai", "MacThai", - new String[] { - "MacThai" // JDK historical - }); - - charset("x-MacSymbol", "MacSymbol", - new String[] { - "MacSymbol" // JDK historical - }); - - charset("x-MacDingbat", "MacDingbat", - new String[] { - "MacDingbat" // JDK historical - }); - - instance = this; - - } - - private boolean initialized = false; - - // If the sun.nio.cs.map property is defined on the command line we won't - // see it in the system-properties table until after the charset subsystem - // has been initialized. We therefore delay the effect of this property - // until after the JRE has completely booted. - // - // At the moment following values for this property are supported, property - // value string is case insensitive. - // - // (1)"Windows-31J/Shift_JIS" - // In 1.4.1 we added a correct implementation of the Shift_JIS charset - // but in previous releases this charset name had been treated as an alias - // for Windows-31J, aka MS932. Users who have existing code that depends - // upon this alias can restore the previous behavior by defining this - // property to have this value. - // - // (2)"x-windows-50221/ISO-2022-JP" - // "x-windows-50220/ISO-2022-JP" - // "x-windows-iso2022jp/ISO-2022-JP" - // The charset ISO-2022-JP is a "standard based" implementation by default, - // which supports ASCII, JIS_X_0201 and JIS_X_0208 mappings based encoding - // and decoding only. - // There are three Microsoft iso-2022-jp variants, namely x-windows-50220, - // x-windows-50221 and x-windows-iso2022jp which behaves "slightly" differently - // compared to the "standard based" implementation. See ISO2022_JP.java for - // detailed description. Users who prefer the behavior of MS iso-2022-jp - // variants should use these names explicitly instead of using "ISO-2022-JP" - // and its aliases. However for those who need the ISO-2022-JP charset behaves - // exactly the same as MS variants do, above properties can be defined to - // switch. - // - // If we need to define other charset-alias mappings in the future then - // this property could be further extended, the general idea being that its - // value should be of the form - // - // new-charset-1/old-charset-1,new-charset-2/old-charset-2,... - // - // where each charset named to the left of a slash is intended to replace - // (most) uses of the charset named to the right of the slash. - // - protected void init() { - if (initialized) - return; - if (!sun.misc.VM.isBooted()) - return; - - String map = getProperty("sun.nio.cs.map"); - boolean sjisIsMS932 = false; - boolean iso2022jpIsMS50221 = false; - boolean iso2022jpIsMS50220 = false; - boolean iso2022jpIsMSISO2022JP = false; - if (map != null) { - String[] maps = map.split(","); - for (int i = 0; i < maps.length; i++) { - if (maps[i].equalsIgnoreCase("Windows-31J/Shift_JIS")) { - sjisIsMS932 = true; - } else if (maps[i].equalsIgnoreCase("x-windows-50221/ISO-2022-JP")) { - iso2022jpIsMS50221 = true; - } else if (maps[i].equalsIgnoreCase("x-windows-50220/ISO-2022-JP")) { - iso2022jpIsMS50220 = true; - } else if (maps[i].equalsIgnoreCase("x-windows-iso2022jp/ISO-2022-JP")) { - iso2022jpIsMSISO2022JP = true; - } - } - } - if (sjisIsMS932) { - deleteCharset("Shift_JIS", - new String[] { - // IANA aliases - "sjis", // historical - "shift_jis", - "shift-jis", - "ms_kanji", - "x-sjis", - "csShiftJIS" - }); - deleteCharset("windows-31j", - new String[] { - "MS932", // JDK historical - "windows-932", - "csWindows31J" - }); - charset("Shift_JIS", "SJIS", - new String[] { - // IANA aliases - "sjis" // JDK historical - }); - charset("windows-31j", "MS932", - new String[] { - "MS932", // JDK historical - "windows-932", - "csWindows31J", - "shift-jis", - "ms_kanji", - "x-sjis", - "csShiftJIS", - // This alias takes precedence over the actual - // Shift_JIS charset itself since aliases are always - // resolved first, before looking up canonical names. - "shift_jis" - }); - } - if (iso2022jpIsMS50221 || - iso2022jpIsMS50220 || - iso2022jpIsMSISO2022JP) { - deleteCharset("ISO-2022-JP", - new String[] { - "iso2022jp", - "jis", - "csISO2022JP", - "jis_encoding", - "csjisencoding" - }); - if (iso2022jpIsMS50221) { - deleteCharset("x-windows-50221", - new String[] { - "cp50221", - "ms50221" - }); - charset("x-windows-50221", "MS50221", - new String[] { - "cp50221", - "ms50221", - "iso-2022-jp", - "iso2022jp", - "jis", - "csISO2022JP", - "jis_encoding", - "csjisencoding" - }); - } else if (iso2022jpIsMS50220) { - deleteCharset("x-windows-50220", - new String[] { - "cp50220", - "ms50220" - }); - charset("x-windows-50220", "MS50220", - new String[] { - "cp50220", - "ms50220", - "iso-2022-jp", - "iso2022jp", - "jis", - "csISO2022JP", - "jis_encoding", - "csjisencoding" - }); - } else { - deleteCharset("x-windows-iso2022jp", - new String[] { - "windows-iso2022jp" - }); - charset("x-windows-iso2022jp", "MSISO2022JP", - new String[] { - "windows-iso2022jp", - "iso-2022-jp", - "iso2022jp", - "jis", - "csISO2022JP", - "jis_encoding", - "csjisencoding" - }); - - - } - } - String osName = getProperty("os.name"); - if ("SunOS".equals(osName) || "Linux".equals(osName) || "AIX".equals(osName) - || osName.contains("OS X")) { - charset("x-COMPOUND_TEXT", "COMPOUND_TEXT", - new String[] { - "COMPOUND_TEXT", // JDK historical - "x11-compound_text", - "x-compound-text" - }); - } - initialized = true; - } - - private static String getProperty(String key) { - // this method may be called during initialization of - // system class loader and thus not using lambda - return AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public String run() { - return System.getProperty(key); - } - }); - } - - public static String[] aliasesFor(String charsetName) { - if (instance == null) - return null; - return instance.aliases(charsetName); - } -} --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/ExtendedCharsets.java.template 2015-02-16 10:41:17.000000000 -0800 @@ -0,0 +1,256 @@ +/* + * Copyright (c) 2000, 2015, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + * + */ + +// -- This file was mechanically generated: Do not edit! -- // + +package sun.nio.cs.ext; + +import java.lang.ref.SoftReference; +import java.nio.charset.Charset; +import java.nio.charset.spi.CharsetProvider; +import sun.nio.cs.AbstractCharsetProvider; +import java.security.AccessController; +import java.security.PrivilegedAction; +import sun.nio.cs.AbstractCharsetProvider; + +/** + * Provider for extended charsets. + */ + +public class ExtendedCharsets extends AbstractCharsetProvider { + + static volatile ExtendedCharsets instance = null; + + public ExtendedCharsets() { + + super("sun.nio.cs.ext"); // identify provider pkg name. + + _CHARSETS_DEF_LIST_ + + instance = this; + + } + + private boolean initialized = false; + + // If the sun.nio.cs.map property is defined on the command line we won't + // see it in the system-properties table until after the charset subsystem + // has been initialized. We therefore delay the effect of this property + // until after the JRE has completely booted. + // + // At the moment following values for this property are supported, property + // value string is case insensitive. + // + // (1)"Windows-31J/Shift_JIS" + // In 1.4.1 we added a correct implementation of the Shift_JIS charset + // but in previous releases this charset name had been treated as an alias + // for Windows-31J, aka MS932. Users who have existing code that depends + // upon this alias can restore the previous behavior by defining this + // property to have this value. + // + // (2)"x-windows-50221/ISO-2022-JP" + // "x-windows-50220/ISO-2022-JP" + // "x-windows-iso2022jp/ISO-2022-JP" + // The charset ISO-2022-JP is a "standard based" implementation by default, + // which supports ASCII, JIS_X_0201 and JIS_X_0208 mappings based encoding + // and decoding only. + // There are three Microsoft iso-2022-jp variants, namely x-windows-50220, + // x-windows-50221 and x-windows-iso2022jp which behaves "slightly" differently + // compared to the "standard based" implementation. See ISO2022_JP.java for + // detailed description. Users who prefer the behavior of MS iso-2022-jp + // variants should use these names explicitly instead of using "ISO-2022-JP" + // and its aliases. However for those who need the ISO-2022-JP charset behaves + // exactly the same as MS variants do, above properties can be defined to + // switch. + // + // If we need to define other charset-alias mappings in the future then + // this property could be further extended, the general idea being that its + // value should be of the form + // + // new-charset-1/old-charset-1,new-charset-2/old-charset-2,... + // + // where each charset named to the left of a slash is intended to replace + // (most) uses of the charset named to the right of the slash. + // + protected void init() { + if (initialized) + return; + if (!sun.misc.VM.isBooted()) + return; + + String map = getProperty("sun.nio.cs.map"); + boolean sjisIsMS932 = false; + boolean iso2022jpIsMS50221 = false; + boolean iso2022jpIsMS50220 = false; + boolean iso2022jpIsMSISO2022JP = false; + if (map != null) { + String[] maps = map.split(","); + for (int i = 0; i < maps.length; i++) { + if (maps[i].equalsIgnoreCase("Windows-31J/Shift_JIS")) { + sjisIsMS932 = true; + } else if (maps[i].equalsIgnoreCase("x-windows-50221/ISO-2022-JP")) { + iso2022jpIsMS50221 = true; + } else if (maps[i].equalsIgnoreCase("x-windows-50220/ISO-2022-JP")) { + iso2022jpIsMS50220 = true; + } else if (maps[i].equalsIgnoreCase("x-windows-iso2022jp/ISO-2022-JP")) { + iso2022jpIsMSISO2022JP = true; + } + } + } + if (sjisIsMS932 && hasCharset("Shift_JIS")) { + deleteCharset("Shift_JIS", + new String[] { + // IANA aliases + "sjis", // historical + "shift_jis", + "shift-jis", + "ms_kanji", + "x-sjis", + "csShiftJIS" + }); + deleteCharset("windows-31j", + new String[] { + "MS932", // JDK historical + "windows-932", + "csWindows31J" + }); + charset("Shift_JIS", "SJIS", + new String[] { + // IANA aliases + "sjis" // JDK historical + }); + charset("windows-31j", "MS932", + new String[] { + "MS932", // JDK historical + "windows-932", + "csWindows31J", + "shift-jis", + "ms_kanji", + "x-sjis", + "csShiftJIS", + // This alias takes precedence over the actual + // Shift_JIS charset itself since aliases are always + // resolved first, before looking up canonical names. + "shift_jis" + }); + } + if (iso2022jpIsMS50221 || + iso2022jpIsMS50220 || + iso2022jpIsMSISO2022JP) { + deleteCharset("ISO-2022-JP", + new String[] { + "iso2022jp", + "jis", + "csISO2022JP", + "jis_encoding", + "csjisencoding" + }); + if (iso2022jpIsMS50221) { + deleteCharset("x-windows-50221", + new String[] { + "cp50221", + "ms50221" + }); + charset("x-windows-50221", "MS50221", + new String[] { + "cp50221", + "ms50221", + "iso-2022-jp", + "iso2022jp", + "jis", + "csISO2022JP", + "jis_encoding", + "csjisencoding" + }); + } else if (iso2022jpIsMS50220) { + deleteCharset("x-windows-50220", + new String[] { + "cp50220", + "ms50220" + }); + charset("x-windows-50220", "MS50220", + new String[] { + "cp50220", + "ms50220", + "iso-2022-jp", + "iso2022jp", + "jis", + "csISO2022JP", + "jis_encoding", + "csjisencoding" + }); + } else { + deleteCharset("x-windows-iso2022jp", + new String[] { + "windows-iso2022jp" + }); + charset("x-windows-iso2022jp", "MSISO2022JP", + new String[] { + "windows-iso2022jp", + "iso-2022-jp", + "iso2022jp", + "jis", + "csISO2022JP", + "jis_encoding", + "csjisencoding" + }); + + + } + } + String osName = getProperty("os.name"); + if ("SunOS".equals(osName) || "Linux".equals(osName) || "AIX".equals(osName) + || osName.contains("OS X")) { + charset("x-COMPOUND_TEXT", "COMPOUND_TEXT", + new String[] { + "COMPOUND_TEXT", // JDK historical + "x11-compound_text", + "x-compound-text" + }); + } + initialized = true; + } + + private static String getProperty(String key) { + // this method may be called during initialization of + // system class loader and thus not using lambda + return AccessController.doPrivileged( + new PrivilegedAction() { + @Override + public String run() { + return System.getProperty(key); + } + }); + } + + public static String[] aliasesFor(String charsetName) { + if (instance == null) + return null; + return instance.aliases(charsetName); + } + +} --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/Big5_HKSCS_2001.java 2015-02-16 10:41:19.000000000 -0800 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/Big5_HKSCS_2001.java 2015-02-16 10:41:18.000000000 -0800 @@ -28,7 +28,9 @@ import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; +import sun.nio.cs.DoubleByte; import sun.nio.cs.HistoricallyNamedCharset; +import sun.nio.cs.*; public class Big5_HKSCS_2001 extends Charset { --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/IBM834.java 2015-02-16 10:41:20.000000000 -0800 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/IBM834.java 2015-02-16 10:41:20.000000000 -0800 @@ -34,6 +34,7 @@ import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; import java.nio.charset.CoderResult; +import sun.nio.cs.DoubleByte; import static sun.nio.cs.CharsetMapping.*; // EBCDIC DBCS-only Korean --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/IBM942C.java 2015-02-16 10:41:21.000000000 -0800 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/IBM942C.java 2015-02-16 10:41:21.000000000 -0800 @@ -29,6 +29,7 @@ import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; import java.util.Arrays; +import sun.nio.cs.DoubleByte; import sun.nio.cs.HistoricallyNamedCharset; import static sun.nio.cs.CharsetMapping.*; --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/IBM943C.java 2015-02-16 10:41:22.000000000 -0800 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/IBM943C.java 2015-02-16 10:41:22.000000000 -0800 @@ -29,6 +29,7 @@ import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; import java.util.Arrays; +import sun.nio.cs.DoubleByte; import sun.nio.cs.HistoricallyNamedCharset; public class IBM943C extends Charset implements HistoricallyNamedCharset --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/IBM949C.java 2015-02-16 10:41:24.000000000 -0800 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/IBM949C.java 2015-02-16 10:41:23.000000000 -0800 @@ -29,6 +29,7 @@ import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; import java.util.Arrays; +import sun.nio.cs.DoubleByte; import sun.nio.cs.HistoricallyNamedCharset; public class IBM949C extends Charset implements HistoricallyNamedCharset --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_CN.java 2015-02-16 10:41:25.000000000 -0800 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_CN.java 2015-02-16 10:41:24.000000000 -0800 @@ -35,8 +35,10 @@ import java.nio.charset.CharsetEncoder; import java.nio.charset.CoderResult; import java.nio.charset.CharacterCodingException; +import sun.nio.cs.DoubleByte; import sun.nio.cs.HistoricallyNamedCharset; import sun.nio.cs.US_ASCII; +import sun.nio.cs.*; public class ISO2022_CN extends Charset --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_CN_GB.java 2015-02-16 10:41:26.000000000 -0800 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_CN_GB.java 2015-02-16 10:41:26.000000000 -0800 @@ -34,6 +34,7 @@ import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; import java.nio.charset.CoderResult; +import sun.nio.cs.*; import sun.nio.cs.HistoricallyNamedCharset; public class ISO2022_CN_GB extends ISO2022 implements HistoricallyNamedCharset --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_JP.java 2015-02-16 10:41:27.000000000 -0800 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_JP.java 2015-02-16 10:41:27.000000000 -0800 @@ -32,9 +32,12 @@ import java.nio.charset.CharsetEncoder; import java.nio.charset.CoderResult; import java.nio.charset.CodingErrorAction; +import sun.nio.cs.DelegatableDecoder; +import sun.nio.cs.DoubleByte; import sun.nio.cs.HistoricallyNamedCharset; import sun.nio.cs.Surrogate; import sun.nio.cs.US_ASCII; +import sun.nio.cs.*; import static sun.nio.cs.CharsetMapping.*; /* --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_JP_2.java 2015-02-16 10:41:29.000000000 -0800 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_JP_2.java 2015-02-16 10:41:28.000000000 -0800 @@ -28,6 +28,8 @@ import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; +import sun.nio.cs.DoubleByte; +import sun.nio.cs.*; public class ISO2022_JP_2 extends ISO2022_JP { --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_KR.java 2015-02-16 10:41:30.000000000 -0800 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_KR.java 2015-02-16 10:41:29.000000000 -0800 @@ -35,7 +35,7 @@ import java.nio.charset.CharsetEncoder; import java.nio.charset.CoderResult; import sun.nio.cs.HistoricallyNamedCharset; -import sun.nio.cs.ext.EUC_KR; +import sun.nio.cs.*; public class ISO2022_KR extends ISO2022 implements HistoricallyNamedCharset --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/JISAutoDetect.java 2015-02-16 10:41:31.000000000 -0800 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/JISAutoDetect.java 2015-02-16 10:41:31.000000000 -0800 @@ -33,9 +33,11 @@ import java.nio.charset.CoderResult; import java.nio.charset.CharacterCodingException; import java.nio.charset.MalformedInputException; +import sun.nio.cs.DelegatableDecoder; import sun.nio.cs.HistoricallyNamedCharset; import java.security.AccessController; import java.security.PrivilegedAction; +import sun.nio.cs.*; import static java.lang.Character.UnicodeBlock; --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/MS50220.java 2015-02-16 10:41:33.000000000 -0800 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/MS50220.java 2015-02-16 10:41:32.000000000 -0800 @@ -28,6 +28,8 @@ import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; +import sun.nio.cs.DoubleByte; +import sun.nio.cs.*; public class MS50220 extends ISO2022_JP { --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/MS50221.java 2015-02-16 10:41:34.000000000 -0800 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/MS50221.java 2015-02-16 10:41:33.000000000 -0800 @@ -26,6 +26,7 @@ package sun.nio.cs.ext; import java.nio.charset.Charset; +import sun.nio.cs.*; public class MS50221 extends MS50220 { --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/MS932_0213.java 2015-02-16 10:41:35.000000000 -0800 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/MS932_0213.java 2015-02-16 10:41:34.000000000 -0800 @@ -28,6 +28,8 @@ import java.nio.charset.Charset; import java.nio.charset.CharsetEncoder; import java.nio.charset.CharsetDecoder; +import sun.nio.cs.DoubleByte; +import sun.nio.cs.*; import static sun.nio.cs.CharsetMapping.*; public class MS932_0213 extends Charset { --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/MS950_HKSCS.java 2015-02-16 10:41:36.000000000 -0800 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/MS950_HKSCS.java 2015-02-16 10:41:36.000000000 -0800 @@ -29,6 +29,7 @@ import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; import sun.nio.cs.HistoricallyNamedCharset; +import sun.nio.cs.*; import static sun.nio.cs.CharsetMapping.*; public class MS950_HKSCS extends Charset implements HistoricallyNamedCharset --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/MSISO2022JP.java 2015-02-16 10:41:37.000000000 -0800 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/MSISO2022JP.java 2015-02-16 10:41:37.000000000 -0800 @@ -28,6 +28,7 @@ import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; +import sun.nio.cs.DoubleByte; public class MSISO2022JP extends ISO2022_JP { --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/SJIS_0213.java 2015-02-16 10:41:39.000000000 -0800 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/SJIS_0213.java 2015-02-16 10:41:38.000000000 -0800 @@ -35,6 +35,7 @@ import java.security.PrivilegedAction; import java.util.Arrays; import sun.nio.cs.CharsetMapping; +import sun.nio.cs.*; /* * 5 types of entry in SJIS_X_0213/Unicode mapping table --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/Big5_HKSCS.java 2015-02-16 10:41:40.000000000 -0800 +++ /dev/null 2014-05-19 13:38:05.886368312 -0700 @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2010, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -package sun.nio.cs.ext; - -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.nio.charset.CharsetEncoder; -import sun.nio.cs.HistoricallyNamedCharset; -import static sun.nio.cs.CharsetMapping.*; - -public class Big5_HKSCS extends Charset implements HistoricallyNamedCharset -{ - public Big5_HKSCS() { - super("Big5-HKSCS", ExtendedCharsets.aliasesFor("Big5-HKSCS")); - } - - public String historicalName() { - return "Big5_HKSCS"; - } - - public boolean contains(Charset cs) { - return ((cs.name().equals("US-ASCII")) - || (cs instanceof Big5) - || (cs instanceof Big5_HKSCS)); - } - - public CharsetDecoder newDecoder() { - return new Decoder(this); - } - - public CharsetEncoder newEncoder() { - return new Encoder(this); - } - - static class Decoder extends HKSCS.Decoder { - private static DoubleByte.Decoder big5 = - (DoubleByte.Decoder)new Big5().newDecoder(); - - private static char[][] b2cBmp = new char[0x100][]; - private static char[][] b2cSupp = new char[0x100][]; - static { - initb2c(b2cBmp, HKSCSMapping.b2cBmpStr); - initb2c(b2cSupp, HKSCSMapping.b2cSuppStr); - } - - private Decoder(Charset cs) { - super(cs, big5, b2cBmp, b2cSupp); - } - } - - static class Encoder extends HKSCS.Encoder { - private static DoubleByte.Encoder big5 = - (DoubleByte.Encoder)new Big5().newEncoder(); - - static char[][] c2bBmp = new char[0x100][]; - static char[][] c2bSupp = new char[0x100][]; - static { - initc2b(c2bBmp, HKSCSMapping.b2cBmpStr, HKSCSMapping.pua); - initc2b(c2bSupp, HKSCSMapping.b2cSuppStr, null); - } - - private Encoder(Charset cs) { - super(cs, big5, c2bBmp, c2bSupp); - } - } -} --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/Big5_HKSCS.java.template 2015-02-16 10:41:39.000000000 -0800 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2010 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package $PACKAGE$; + +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.CharsetEncoder; +import sun.nio.cs.DoubleByte; +import sun.nio.cs.HKSCS; +import sun.nio.cs.HistoricallyNamedCharset; +import static sun.nio.cs.CharsetMapping.*; + +public class Big5_HKSCS extends Charset implements HistoricallyNamedCharset +{ + public Big5_HKSCS() { + super("Big5-HKSCS", $ALIASES$); + } + + public String historicalName() { + return "Big5_HKSCS"; + } + + public boolean contains(Charset cs) { + return ((cs.name().equals("US-ASCII")) + || (cs instanceof Big5) + || (cs instanceof Big5_HKSCS)); + } + + public CharsetDecoder newDecoder() { + return new Decoder(this); + } + + public CharsetEncoder newEncoder() { + return new Encoder(this); + } + + static class Decoder extends HKSCS.Decoder { + private static DoubleByte.Decoder big5 = + (DoubleByte.Decoder)new Big5().newDecoder(); + + private static char[][] b2cBmp = new char[0x100][]; + private static char[][] b2cSupp = new char[0x100][]; + static { + initb2c(b2cBmp, HKSCSMapping.b2cBmpStr); + initb2c(b2cSupp, HKSCSMapping.b2cSuppStr); + } + + private Decoder(Charset cs) { + super(cs, big5, b2cBmp, b2cSupp); + } + } + + static class Encoder extends HKSCS.Encoder { + private static DoubleByte.Encoder big5 = + (DoubleByte.Encoder)new Big5().newEncoder(); + + static char[][] c2bBmp = new char[0x100][]; + static char[][] c2bSupp = new char[0x100][]; + static { + initc2b(c2bBmp, HKSCSMapping.b2cBmpStr, HKSCSMapping.pua); + initc2b(c2bSupp, HKSCSMapping.b2cSuppStr, null); + } + + private Encoder(Charset cs) { + super(cs, big5, c2bBmp, c2bSupp); + } + } +} --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/Big5_Solaris.java 2015-02-16 10:41:41.000000000 -0800 +++ /dev/null 2014-05-19 13:38:05.886368312 -0700 @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2004, 2010, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -package sun.nio.cs.ext; - -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.nio.charset.CharsetEncoder; -import sun.nio.cs.HistoricallyNamedCharset; -import java.util.Arrays; -import static sun.nio.cs.CharsetMapping.*; - -public class Big5_Solaris extends Charset implements HistoricallyNamedCharset -{ - public Big5_Solaris() { - super("x-Big5-Solaris", ExtendedCharsets.aliasesFor("x-Big5-Solaris")); - } - - public String historicalName() { - return "Big5_Solaris"; - } - - public boolean contains(Charset cs) { - return ((cs.name().equals("US-ASCII")) - || (cs instanceof Big5) - || (cs instanceof Big5_Solaris)); - } - - public CharsetDecoder newDecoder() { - initb2c(); - return new DoubleByte.Decoder(this, b2c, b2cSB, 0x40, 0xfe); - } - - public CharsetEncoder newEncoder() { - initc2b(); - return new DoubleByte.Encoder(this, c2b, c2bIndex); - } - - static char[][] b2c; - static char[] b2cSB; - private static volatile boolean b2cInitialized = false; - - static void initb2c() { - if (b2cInitialized) - return; - synchronized (Big5_Solaris.class) { - if (b2cInitialized) - return; - Big5.initb2c(); - b2c = Big5.b2c.clone(); - // Big5 Solaris implementation has 7 additional mappings - int[] sol = new int[] { - 0xF9D6, 0x7881, - 0xF9D7, 0x92B9, - 0xF9D8, 0x88CF, - 0xF9D9, 0x58BB, - 0xF9DA, 0x6052, - 0xF9DB, 0x7CA7, - 0xF9DC, 0x5AFA }; - if (b2c[0xf9] == DoubleByte.B2C_UNMAPPABLE) { - b2c[0xf9] = new char[0xfe - 0x40 + 1]; - Arrays.fill(b2c[0xf9], UNMAPPABLE_DECODING); - } - - for (int i = 0; i < sol.length;) { - b2c[0xf9][sol[i++] & 0xff - 0x40] = (char)sol[i++]; - } - b2cSB = Big5.b2cSB; - b2cInitialized = true; - } - } - - static char[] c2b; - static char[] c2bIndex; - private static volatile boolean c2bInitialized = false; - - static void initc2b() { - if (c2bInitialized) - return; - synchronized (Big5_Solaris.class) { - if (c2bInitialized) - return; - Big5.initc2b(); - c2b = Big5.c2b.clone(); - c2bIndex = Big5.c2bIndex.clone(); - int[] sol = new int[] { - 0x7881, 0xF9D6, - 0x92B9, 0xF9D7, - 0x88CF, 0xF9D8, - 0x58BB, 0xF9D9, - 0x6052, 0xF9DA, - 0x7CA7, 0xF9DB, - 0x5AFA, 0xF9DC }; - - for (int i = 0; i < sol.length;) { - int c = sol[i++]; - // no need to check c2bIndex[c >>8], we know it points - // to the appropriate place. - c2b[c2bIndex[c >> 8] + (c & 0xff)] = (char)sol[i++]; - } - c2bInitialized = true; - } - } -} --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/Big5_Solaris.java.template 2015-02-16 10:41:41.000000000 -0800 @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2004, 2010, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package $PACKAGE$; + +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.CharsetEncoder; +import sun.nio.cs.DoubleByte; +import sun.nio.cs.HistoricallyNamedCharset; +import java.util.Arrays; +import static sun.nio.cs.CharsetMapping.*; + +public class Big5_Solaris extends Charset implements HistoricallyNamedCharset +{ + public Big5_Solaris() { + super("x-Big5-Solaris", $ALIASES$); + } + + public String historicalName() { + return "Big5_Solaris"; + } + + public boolean contains(Charset cs) { + return ((cs.name().equals("US-ASCII")) + || (cs instanceof Big5) + || (cs instanceof Big5_Solaris)); + } + + public CharsetDecoder newDecoder() { + initb2c(); + return new DoubleByte.Decoder(this, b2c, b2cSB, 0x40, 0xfe); + } + + public CharsetEncoder newEncoder() { + initc2b(); + return new DoubleByte.Encoder(this, c2b, c2bIndex); + } + + static char[][] b2c; + static char[] b2cSB; + private static volatile boolean b2cInitialized = false; + + static void initb2c() { + if (b2cInitialized) + return; + synchronized (Big5_Solaris.class) { + if (b2cInitialized) + return; + Big5.initb2c(); + b2c = Big5.b2c.clone(); + // Big5 Solaris implementation has 7 additional mappings + int[] sol = new int[] { + 0xF9D6, 0x7881, + 0xF9D7, 0x92B9, + 0xF9D8, 0x88CF, + 0xF9D9, 0x58BB, + 0xF9DA, 0x6052, + 0xF9DB, 0x7CA7, + 0xF9DC, 0x5AFA }; + if (b2c[0xf9] == DoubleByte.B2C_UNMAPPABLE) { + b2c[0xf9] = new char[0xfe - 0x40 + 1]; + Arrays.fill(b2c[0xf9], UNMAPPABLE_DECODING); + } + + for (int i = 0; i < sol.length;) { + b2c[0xf9][sol[i++] & 0xff - 0x40] = (char)sol[i++]; + } + b2cSB = Big5.b2cSB; + b2cInitialized = true; + } + } + + static char[] c2b; + static char[] c2bIndex; + private static volatile boolean c2bInitialized = false; + + static void initc2b() { + if (c2bInitialized) + return; + synchronized (Big5_Solaris.class) { + if (c2bInitialized) + return; + Big5.initc2b(); + c2b = Big5.c2b.clone(); + c2bIndex = Big5.c2bIndex.clone(); + int[] sol = new int[] { + 0x7881, 0xF9D6, + 0x92B9, 0xF9D7, + 0x88CF, 0xF9D8, + 0x58BB, 0xF9D9, + 0x6052, 0xF9DA, + 0x7CA7, 0xF9DB, + 0x5AFA, 0xF9DC }; + + for (int i = 0; i < sol.length;) { + int c = sol[i++]; + // no need to check c2bIndex[c >>8], we know it points + // to the appropriate place. + c2b[c2bIndex[c >> 8] + (c & 0xff)] = (char)sol[i++]; + } + c2bInitialized = true; + } + } +} --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/EUC_JP.java 2015-02-16 10:41:42.000000000 -0800 +++ /dev/null 2014-05-19 13:38:05.886368312 -0700 @@ -1,411 +0,0 @@ -/* - * Copyright (c) 2002, 2012, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -package sun.nio.cs.ext; - -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.nio.charset.CharsetEncoder; -import java.nio.charset.CoderResult; -import sun.nio.cs.HistoricallyNamedCharset; -import sun.nio.cs.Surrogate; -import sun.nio.cs.SingleByte; -import static sun.nio.cs.CharsetMapping.*; - -public class EUC_JP - extends Charset - implements HistoricallyNamedCharset -{ - public EUC_JP() { - super("EUC-JP", ExtendedCharsets.aliasesFor("EUC-JP")); - } - - public String historicalName() { - return "EUC_JP"; - } - - public boolean contains(Charset cs) { - return ((cs.name().equals("US-ASCII")) - || (cs instanceof JIS_X_0201) - || (cs instanceof JIS_X_0208) - || (cs instanceof JIS_X_0212) - || (cs instanceof EUC_JP)); - } - - public CharsetDecoder newDecoder() { - return new Decoder(this); - } - - public CharsetEncoder newEncoder() { - return new Encoder(this); - } - - static class Decoder extends CharsetDecoder - implements DelegatableDecoder { - - final static SingleByte.Decoder DEC0201 = - (SingleByte.Decoder)new JIS_X_0201().newDecoder(); - - final static DoubleByte.Decoder DEC0208 = - (DoubleByte.Decoder)new JIS_X_0208().newDecoder(); - - final static DoubleByte.Decoder DEC0212 = - (DoubleByte.Decoder)new JIS_X_0212().newDecoder(); - - private final SingleByte.Decoder dec0201; - private final DoubleByte.Decoder dec0208; - private final DoubleByte.Decoder dec0212; - - protected Decoder(Charset cs) { - this(cs, 0.5f, 1.0f, DEC0201, DEC0208, DEC0212); - } - - protected Decoder(Charset cs, float avgCpb, float maxCpb, - SingleByte.Decoder dec0201, - DoubleByte.Decoder dec0208, - DoubleByte.Decoder dec0212) { - super(cs, avgCpb, maxCpb); - this.dec0201 = dec0201; - this.dec0208 = dec0208; - this.dec0212 = dec0212; - } - - - protected char decodeDouble(int byte1, int byte2) { - if (byte1 == 0x8e) { - if (byte2 < 0x80) - return UNMAPPABLE_DECODING; - return dec0201.decode((byte)byte2); - } - return dec0208.decodeDouble(byte1 - 0x80, byte2 - 0x80); - } - - private CoderResult decodeArrayLoop(ByteBuffer src, - CharBuffer dst) - { - byte[] sa = src.array(); - int sp = src.arrayOffset() + src.position(); - int sl = src.arrayOffset() + src.limit(); - assert (sp <= sl); - sp = (sp <= sl ? sp : sl); - - char[] da = dst.array(); - int dp = dst.arrayOffset() + dst.position(); - int dl = dst.arrayOffset() + dst.limit(); - assert (dp <= dl); - dp = (dp <= dl ? dp : dl); - - int b1 = 0, b2 = 0; - int inputSize = 0; - char outputChar = UNMAPPABLE_DECODING; - try { - while (sp < sl) { - b1 = sa[sp] & 0xff; - inputSize = 1; - - if ((b1 & 0x80) == 0) { - outputChar = (char)b1; - } else { // Multibyte char - if (b1 == 0x8f) { // JIS0212 - if (sp + 3 > sl) - return CoderResult.UNDERFLOW; - b1 = sa[sp + 1] & 0xff; - b2 = sa[sp + 2] & 0xff; - inputSize += 2; - if (dec0212 == null) // JIS02012 not supported - return CoderResult.unmappableForLength(inputSize); - outputChar = dec0212.decodeDouble(b1-0x80, b2-0x80); - } else { // JIS0201, JIS0208 - if (sp + 2 > sl) - return CoderResult.UNDERFLOW; - b2 = sa[sp + 1] & 0xff; - inputSize++; - outputChar = decodeDouble(b1, b2); - } - } - if (outputChar == UNMAPPABLE_DECODING) { // can't be decoded - return CoderResult.unmappableForLength(inputSize); - } - if (dp + 1 > dl) - return CoderResult.OVERFLOW; - da[dp++] = outputChar; - sp += inputSize; - } - return CoderResult.UNDERFLOW; - } finally { - src.position(sp - src.arrayOffset()); - dst.position(dp - dst.arrayOffset()); - } - } - - private CoderResult decodeBufferLoop(ByteBuffer src, - CharBuffer dst) - { - int mark = src.position(); - int b1 = 0, b2 = 0; - int inputSize = 0; - char outputChar = UNMAPPABLE_DECODING; - - try { - while (src.hasRemaining()) { - b1 = src.get() & 0xff; - inputSize = 1; - if ((b1 & 0x80) == 0) { - outputChar = (char)b1; - } else { // Multibyte char - if (b1 == 0x8f) { // JIS0212 - if (src.remaining() < 2) - return CoderResult.UNDERFLOW; - b1 = src.get() & 0xff; - b2 = src.get() & 0xff; - inputSize += 2; - if (dec0212 == null) // JIS02012 not supported - return CoderResult.unmappableForLength(inputSize); - outputChar = dec0212.decodeDouble(b1-0x80, b2-0x80); - } else { // JIS0201 JIS0208 - if (src.remaining() < 1) - return CoderResult.UNDERFLOW; - b2 = src.get() & 0xff; - inputSize++; - outputChar = decodeDouble(b1, b2); - } - } - if (outputChar == UNMAPPABLE_DECODING) { - return CoderResult.unmappableForLength(inputSize); - } - if (dst.remaining() < 1) - return CoderResult.OVERFLOW; - dst.put(outputChar); - mark += inputSize; - } - return CoderResult.UNDERFLOW; - } finally { - src.position(mark); - } - } - - // Make some protected methods public for use by JISAutoDetect - public CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) { - if (src.hasArray() && dst.hasArray()) - return decodeArrayLoop(src, dst); - else - return decodeBufferLoop(src, dst); - } - public void implReset() { - super.implReset(); - } - public CoderResult implFlush(CharBuffer out) { - return super.implFlush(out); - } - } - - - static class Encoder extends CharsetEncoder { - - final static SingleByte.Encoder ENC0201 = - (SingleByte.Encoder)new JIS_X_0201().newEncoder(); - - final static DoubleByte.Encoder ENC0208 = - (DoubleByte.Encoder)new JIS_X_0208().newEncoder(); - - final static DoubleByte.Encoder ENC0212 = - (DoubleByte.Encoder)new JIS_X_0212().newEncoder(); - - private final Surrogate.Parser sgp = new Surrogate.Parser(); - - - private final SingleByte.Encoder enc0201; - private final DoubleByte.Encoder enc0208; - private final DoubleByte.Encoder enc0212; - - protected Encoder(Charset cs) { - this(cs, 3.0f, 3.0f, ENC0201, ENC0208, ENC0212); - } - - protected Encoder(Charset cs, float avgBpc, float maxBpc, - SingleByte.Encoder enc0201, - DoubleByte.Encoder enc0208, - DoubleByte.Encoder enc0212) { - super(cs, avgBpc, maxBpc); - this.enc0201 = enc0201; - this.enc0208 = enc0208; - this.enc0212 = enc0212; - } - - public boolean canEncode(char c) { - byte[] encodedBytes = new byte[3]; - return encodeSingle(c, encodedBytes) != 0 || - encodeDouble(c) != UNMAPPABLE_ENCODING; - } - - protected int encodeSingle(char inputChar, byte[] outputByte) { - int b = enc0201.encode(inputChar); - if (b == UNMAPPABLE_ENCODING) - return 0; - if (b >= 0 && b < 128) { - outputByte[0] = (byte)b; - return 1; - } - outputByte[0] = (byte)0x8e; - outputByte[1] = (byte)b; - return 2; - } - - protected int encodeDouble(char ch) { - int b = enc0208.encodeChar(ch); - if (b != UNMAPPABLE_ENCODING) - return b + 0x8080; - if (enc0212 != null) { - b = enc0212.encodeChar(ch); - if (b != UNMAPPABLE_ENCODING) - b += 0x8F8080; - } - return b; - } - - private CoderResult encodeArrayLoop(CharBuffer src, - ByteBuffer dst) - { - char[] sa = src.array(); - int sp = src.arrayOffset() + src.position(); - int sl = src.arrayOffset() + src.limit(); - assert (sp <= sl); - sp = (sp <= sl ? sp : sl); - byte[] da = dst.array(); - int dp = dst.arrayOffset() + dst.position(); - int dl = dst.arrayOffset() + dst.limit(); - assert (dp <= dl); - dp = (dp <= dl ? dp : dl); - - int outputSize = 0; - byte[] outputByte; - int inputSize = 0; // Size of input - byte[] tmpBuf = new byte[3]; - - try { - while (sp < sl) { - outputByte = tmpBuf; - char c = sa[sp]; - if (Character.isSurrogate(c)) { - if (sgp.parse(c, sa, sp, sl) < 0) - return sgp.error(); - return sgp.unmappableResult(); - } - outputSize = encodeSingle(c, outputByte); - if (outputSize == 0) { // DoubleByte - int ncode = encodeDouble(c); - if (ncode != UNMAPPABLE_ENCODING) { - if ((ncode & 0xFF0000) == 0) { - outputByte[0] = (byte) ((ncode & 0xff00) >> 8); - outputByte[1] = (byte) (ncode & 0xff); - outputSize = 2; - } else { - outputByte[0] = (byte) 0x8f; - outputByte[1] = (byte) ((ncode & 0xff00) >> 8); - outputByte[2] = (byte) (ncode & 0xff); - outputSize = 3; - } - } else { - return CoderResult.unmappableForLength(1); - } - } - if (dl - dp < outputSize) - return CoderResult.OVERFLOW; - // Put the byte in the output buffer - for (int i = 0; i < outputSize; i++) { - da[dp++] = outputByte[i]; - } - sp++; - } - return CoderResult.UNDERFLOW; - } finally { - src.position(sp - src.arrayOffset()); - dst.position(dp - dst.arrayOffset()); - } - } - - private CoderResult encodeBufferLoop(CharBuffer src, - ByteBuffer dst) - { - int outputSize = 0; - byte[] outputByte; - int inputSize = 0; // Size of input - byte[] tmpBuf = new byte[3]; - - int mark = src.position(); - - try { - while (src.hasRemaining()) { - outputByte = tmpBuf; - char c = src.get(); - if (Character.isSurrogate(c)) { - if (sgp.parse(c, src) < 0) - return sgp.error(); - return sgp.unmappableResult(); - } - outputSize = encodeSingle(c, outputByte); - if (outputSize == 0) { // DoubleByte - int ncode = encodeDouble(c); - if (ncode != UNMAPPABLE_ENCODING) { - if ((ncode & 0xFF0000) == 0) { - outputByte[0] = (byte) ((ncode & 0xff00) >> 8); - outputByte[1] = (byte) (ncode & 0xff); - outputSize = 2; - } else { - outputByte[0] = (byte) 0x8f; - outputByte[1] = (byte) ((ncode & 0xff00) >> 8); - outputByte[2] = (byte) (ncode & 0xff); - outputSize = 3; - } - } else { - return CoderResult.unmappableForLength(1); - } - } - if (dst.remaining() < outputSize) - return CoderResult.OVERFLOW; - // Put the byte in the output buffer - for (int i = 0; i < outputSize; i++) { - dst.put(outputByte[i]); - } - mark++; - } - return CoderResult.UNDERFLOW; - } finally { - src.position(mark); - } - } - - protected CoderResult encodeLoop(CharBuffer src, - ByteBuffer dst) - { - if (src.hasArray() && dst.hasArray()) - return encodeArrayLoop(src, dst); - else - return encodeBufferLoop(src, dst); - } - } -} --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/EUC_JP.java.template 2015-02-16 10:41:42.000000000 -0800 @@ -0,0 +1,414 @@ +/* + * Copyright (c) 2002, 2012, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package $PACKAGE$; + +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.CharsetEncoder; +import java.nio.charset.CoderResult; +import sun.nio.cs.HistoricallyNamedCharset; +import sun.nio.cs.DelegatableDecoder; +import sun.nio.cs.DoubleByte; +import sun.nio.cs.Surrogate; +import sun.nio.cs.SingleByte; +import sun.nio.cs.*; +import static sun.nio.cs.CharsetMapping.*; + +public class EUC_JP + extends Charset + implements HistoricallyNamedCharset +{ + public EUC_JP() { + super("EUC-JP", $ALIASES$); + } + + public String historicalName() { + return "EUC_JP"; + } + + public boolean contains(Charset cs) { + return ((cs.name().equals("US-ASCII")) + || (cs instanceof JIS_X_0201) + || (cs instanceof JIS_X_0208) + || (cs instanceof JIS_X_0212) + || (cs instanceof EUC_JP)); + } + + public CharsetDecoder newDecoder() { + return new Decoder(this); + } + + public CharsetEncoder newEncoder() { + return new Encoder(this); + } + + static class Decoder extends CharsetDecoder + implements DelegatableDecoder { + + final static SingleByte.Decoder DEC0201 = + (SingleByte.Decoder)new JIS_X_0201().newDecoder(); + + final static DoubleByte.Decoder DEC0208 = + (DoubleByte.Decoder)new JIS_X_0208().newDecoder(); + + final static DoubleByte.Decoder DEC0212 = + (DoubleByte.Decoder)new JIS_X_0212().newDecoder(); + + private final SingleByte.Decoder dec0201; + private final DoubleByte.Decoder dec0208; + private final DoubleByte.Decoder dec0212; + + protected Decoder(Charset cs) { + this(cs, 0.5f, 1.0f, DEC0201, DEC0208, DEC0212); + } + + protected Decoder(Charset cs, float avgCpb, float maxCpb, + SingleByte.Decoder dec0201, + DoubleByte.Decoder dec0208, + DoubleByte.Decoder dec0212) { + super(cs, avgCpb, maxCpb); + this.dec0201 = dec0201; + this.dec0208 = dec0208; + this.dec0212 = dec0212; + } + + + protected char decodeDouble(int byte1, int byte2) { + if (byte1 == 0x8e) { + if (byte2 < 0x80) + return UNMAPPABLE_DECODING; + return dec0201.decode((byte)byte2); + } + return dec0208.decodeDouble(byte1 - 0x80, byte2 - 0x80); + } + + private CoderResult decodeArrayLoop(ByteBuffer src, + CharBuffer dst) + { + byte[] sa = src.array(); + int sp = src.arrayOffset() + src.position(); + int sl = src.arrayOffset() + src.limit(); + assert (sp <= sl); + sp = (sp <= sl ? sp : sl); + + char[] da = dst.array(); + int dp = dst.arrayOffset() + dst.position(); + int dl = dst.arrayOffset() + dst.limit(); + assert (dp <= dl); + dp = (dp <= dl ? dp : dl); + + int b1 = 0, b2 = 0; + int inputSize = 0; + char outputChar = UNMAPPABLE_DECODING; + try { + while (sp < sl) { + b1 = sa[sp] & 0xff; + inputSize = 1; + + if ((b1 & 0x80) == 0) { + outputChar = (char)b1; + } else { // Multibyte char + if (b1 == 0x8f) { // JIS0212 + if (sp + 3 > sl) + return CoderResult.UNDERFLOW; + b1 = sa[sp + 1] & 0xff; + b2 = sa[sp + 2] & 0xff; + inputSize += 2; + if (dec0212 == null) // JIS02012 not supported + return CoderResult.unmappableForLength(inputSize); + outputChar = dec0212.decodeDouble(b1-0x80, b2-0x80); + } else { // JIS0201, JIS0208 + if (sp + 2 > sl) + return CoderResult.UNDERFLOW; + b2 = sa[sp + 1] & 0xff; + inputSize++; + outputChar = decodeDouble(b1, b2); + } + } + if (outputChar == UNMAPPABLE_DECODING) { // can't be decoded + return CoderResult.unmappableForLength(inputSize); + } + if (dp + 1 > dl) + return CoderResult.OVERFLOW; + da[dp++] = outputChar; + sp += inputSize; + } + return CoderResult.UNDERFLOW; + } finally { + src.position(sp - src.arrayOffset()); + dst.position(dp - dst.arrayOffset()); + } + } + + private CoderResult decodeBufferLoop(ByteBuffer src, + CharBuffer dst) + { + int mark = src.position(); + int b1 = 0, b2 = 0; + int inputSize = 0; + char outputChar = UNMAPPABLE_DECODING; + + try { + while (src.hasRemaining()) { + b1 = src.get() & 0xff; + inputSize = 1; + if ((b1 & 0x80) == 0) { + outputChar = (char)b1; + } else { // Multibyte char + if (b1 == 0x8f) { // JIS0212 + if (src.remaining() < 2) + return CoderResult.UNDERFLOW; + b1 = src.get() & 0xff; + b2 = src.get() & 0xff; + inputSize += 2; + if (dec0212 == null) // JIS02012 not supported + return CoderResult.unmappableForLength(inputSize); + outputChar = dec0212.decodeDouble(b1-0x80, b2-0x80); + } else { // JIS0201 JIS0208 + if (src.remaining() < 1) + return CoderResult.UNDERFLOW; + b2 = src.get() & 0xff; + inputSize++; + outputChar = decodeDouble(b1, b2); + } + } + if (outputChar == UNMAPPABLE_DECODING) { + return CoderResult.unmappableForLength(inputSize); + } + if (dst.remaining() < 1) + return CoderResult.OVERFLOW; + dst.put(outputChar); + mark += inputSize; + } + return CoderResult.UNDERFLOW; + } finally { + src.position(mark); + } + } + + // Make some protected methods public for use by JISAutoDetect + public CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) { + if (src.hasArray() && dst.hasArray()) + return decodeArrayLoop(src, dst); + else + return decodeBufferLoop(src, dst); + } + public void implReset() { + super.implReset(); + } + public CoderResult implFlush(CharBuffer out) { + return super.implFlush(out); + } + } + + + static class Encoder extends CharsetEncoder { + + final static SingleByte.Encoder ENC0201 = + (SingleByte.Encoder)new JIS_X_0201().newEncoder(); + + final static DoubleByte.Encoder ENC0208 = + (DoubleByte.Encoder)new JIS_X_0208().newEncoder(); + + final static DoubleByte.Encoder ENC0212 = + (DoubleByte.Encoder)new JIS_X_0212().newEncoder(); + + private final Surrogate.Parser sgp = new Surrogate.Parser(); + + + private final SingleByte.Encoder enc0201; + private final DoubleByte.Encoder enc0208; + private final DoubleByte.Encoder enc0212; + + protected Encoder(Charset cs) { + this(cs, 3.0f, 3.0f, ENC0201, ENC0208, ENC0212); + } + + protected Encoder(Charset cs, float avgBpc, float maxBpc, + SingleByte.Encoder enc0201, + DoubleByte.Encoder enc0208, + DoubleByte.Encoder enc0212) { + super(cs, avgBpc, maxBpc); + this.enc0201 = enc0201; + this.enc0208 = enc0208; + this.enc0212 = enc0212; + } + + public boolean canEncode(char c) { + byte[] encodedBytes = new byte[3]; + return encodeSingle(c, encodedBytes) != 0 || + encodeDouble(c) != UNMAPPABLE_ENCODING; + } + + protected int encodeSingle(char inputChar, byte[] outputByte) { + int b = enc0201.encode(inputChar); + if (b == UNMAPPABLE_ENCODING) + return 0; + if (b >= 0 && b < 128) { + outputByte[0] = (byte)b; + return 1; + } + outputByte[0] = (byte)0x8e; + outputByte[1] = (byte)b; + return 2; + } + + protected int encodeDouble(char ch) { + int b = enc0208.encodeChar(ch); + if (b != UNMAPPABLE_ENCODING) + return b + 0x8080; + if (enc0212 != null) { + b = enc0212.encodeChar(ch); + if (b != UNMAPPABLE_ENCODING) + b += 0x8F8080; + } + return b; + } + + private CoderResult encodeArrayLoop(CharBuffer src, + ByteBuffer dst) + { + char[] sa = src.array(); + int sp = src.arrayOffset() + src.position(); + int sl = src.arrayOffset() + src.limit(); + assert (sp <= sl); + sp = (sp <= sl ? sp : sl); + byte[] da = dst.array(); + int dp = dst.arrayOffset() + dst.position(); + int dl = dst.arrayOffset() + dst.limit(); + assert (dp <= dl); + dp = (dp <= dl ? dp : dl); + + int outputSize = 0; + byte[] outputByte; + int inputSize = 0; // Size of input + byte[] tmpBuf = new byte[3]; + + try { + while (sp < sl) { + outputByte = tmpBuf; + char c = sa[sp]; + if (Character.isSurrogate(c)) { + if (sgp.parse(c, sa, sp, sl) < 0) + return sgp.error(); + return sgp.unmappableResult(); + } + outputSize = encodeSingle(c, outputByte); + if (outputSize == 0) { // DoubleByte + int ncode = encodeDouble(c); + if (ncode != UNMAPPABLE_ENCODING) { + if ((ncode & 0xFF0000) == 0) { + outputByte[0] = (byte) ((ncode & 0xff00) >> 8); + outputByte[1] = (byte) (ncode & 0xff); + outputSize = 2; + } else { + outputByte[0] = (byte) 0x8f; + outputByte[1] = (byte) ((ncode & 0xff00) >> 8); + outputByte[2] = (byte) (ncode & 0xff); + outputSize = 3; + } + } else { + return CoderResult.unmappableForLength(1); + } + } + if (dl - dp < outputSize) + return CoderResult.OVERFLOW; + // Put the byte in the output buffer + for (int i = 0; i < outputSize; i++) { + da[dp++] = outputByte[i]; + } + sp++; + } + return CoderResult.UNDERFLOW; + } finally { + src.position(sp - src.arrayOffset()); + dst.position(dp - dst.arrayOffset()); + } + } + + private CoderResult encodeBufferLoop(CharBuffer src, + ByteBuffer dst) + { + int outputSize = 0; + byte[] outputByte; + int inputSize = 0; // Size of input + byte[] tmpBuf = new byte[3]; + + int mark = src.position(); + + try { + while (src.hasRemaining()) { + outputByte = tmpBuf; + char c = src.get(); + if (Character.isSurrogate(c)) { + if (sgp.parse(c, src) < 0) + return sgp.error(); + return sgp.unmappableResult(); + } + outputSize = encodeSingle(c, outputByte); + if (outputSize == 0) { // DoubleByte + int ncode = encodeDouble(c); + if (ncode != UNMAPPABLE_ENCODING) { + if ((ncode & 0xFF0000) == 0) { + outputByte[0] = (byte) ((ncode & 0xff00) >> 8); + outputByte[1] = (byte) (ncode & 0xff); + outputSize = 2; + } else { + outputByte[0] = (byte) 0x8f; + outputByte[1] = (byte) ((ncode & 0xff00) >> 8); + outputByte[2] = (byte) (ncode & 0xff); + outputSize = 3; + } + } else { + return CoderResult.unmappableForLength(1); + } + } + if (dst.remaining() < outputSize) + return CoderResult.OVERFLOW; + // Put the byte in the output buffer + for (int i = 0; i < outputSize; i++) { + dst.put(outputByte[i]); + } + mark++; + } + return CoderResult.UNDERFLOW; + } finally { + src.position(mark); + } + } + + protected CoderResult encodeLoop(CharBuffer src, + ByteBuffer dst) + { + if (src.hasArray() && dst.hasArray()) + return encodeArrayLoop(src, dst); + else + return encodeBufferLoop(src, dst); + } + } +} --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/EUC_JP_LINUX.java 2015-02-16 10:41:43.000000000 -0800 +++ /dev/null 2014-05-19 13:38:05.886368312 -0700 @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2002, 2012, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -package sun.nio.cs.ext; - -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.nio.charset.CharsetEncoder; -import java.nio.charset.CoderResult; -import sun.nio.cs.HistoricallyNamedCharset; - -public class EUC_JP_LINUX - extends Charset - implements HistoricallyNamedCharset -{ - public EUC_JP_LINUX() { - super("x-euc-jp-linux", ExtendedCharsets.aliasesFor("x-euc-jp-linux")); - } - - public String historicalName() { - return "EUC_JP_LINUX"; - } - - public boolean contains(Charset cs) { - return ((cs instanceof JIS_X_0201) - || (cs.name().equals("US-ASCII")) - || (cs instanceof EUC_JP_LINUX)); - } - - public CharsetDecoder newDecoder() { - return new Decoder(this); - } - - public CharsetEncoder newEncoder() { - return new Encoder(this); - } - - private static class Decoder extends EUC_JP.Decoder { - private Decoder(Charset cs) { - super(cs, 1.0f, 1.0f, DEC0201, DEC0208, null); - } - } - - private static class Encoder extends EUC_JP.Encoder { - private Encoder(Charset cs) { - super(cs, 2.0f, 2.0f, ENC0201, ENC0208, null); - } - } -} --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/EUC_JP_LINUX.java.template 2015-02-16 10:41:43.000000000 -0800 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2002, 2015, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package $PACKAGE$; + +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.CharsetEncoder; +import java.nio.charset.CoderResult; +import sun.nio.cs.HistoricallyNamedCharset; +import sun.nio.cs.*; + +public class EUC_JP_LINUX + extends Charset + implements HistoricallyNamedCharset +{ + public EUC_JP_LINUX() { + super("x-euc-jp-linux", $ALIASES$); + } + + public String historicalName() { + return "EUC_JP_LINUX"; + } + + public boolean contains(Charset cs) { + return ((cs instanceof JIS_X_0201) + || (cs.name().equals("US-ASCII")) + || (cs instanceof EUC_JP_LINUX)); + } + + public CharsetDecoder newDecoder() { + return new Decoder(this); + } + + public CharsetEncoder newEncoder() { + return new Encoder(this); + } + + private static class Decoder extends EUC_JP.Decoder { + private Decoder(Charset cs) { + super(cs, 1.0f, 1.0f, DEC0201, DEC0208, null); + } + } + + private static class Encoder extends EUC_JP.Encoder { + private Encoder(Charset cs) { + super(cs, 2.0f, 2.0f, ENC0201, ENC0208, null); + } + } +} --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/EUC_JP_Open.java 2015-02-16 10:41:45.000000000 -0800 +++ /dev/null 2014-05-19 13:38:05.886368312 -0700 @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2003, 2012, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -package sun.nio.cs.ext; - -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.nio.charset.CharsetEncoder; -import java.nio.charset.CoderResult; -import sun.nio.cs.HistoricallyNamedCharset; -import static sun.nio.cs.CharsetMapping.*; - -public class EUC_JP_Open - extends Charset - implements HistoricallyNamedCharset -{ - public EUC_JP_Open() { - super("x-eucJP-Open", ExtendedCharsets.aliasesFor("x-eucJP-Open")); - } - - public String historicalName() { - return "EUC_JP_Solaris"; - } - - public boolean contains(Charset cs) { - return ((cs.name().equals("US-ASCII")) - || (cs instanceof JIS_X_0201) - || (cs instanceof EUC_JP)); - } - - public CharsetDecoder newDecoder() { - return new Decoder(this); - } - - public CharsetEncoder newEncoder() { - return new Encoder(this); - } - - private static class Decoder extends EUC_JP.Decoder { - private static DoubleByte.Decoder DEC0208_Solaris = - (DoubleByte.Decoder)new JIS_X_0208_Solaris().newDecoder(); - private static DoubleByte.Decoder DEC0212_Solaris = - (DoubleByte.Decoder)new JIS_X_0212_Solaris().newDecoder(); - - private Decoder(Charset cs) { - // JIS_X_0208_Solaris only has the "extra" mappings, it - // does not have the JIS_X_0208 entries - super(cs, 0.5f, 1.0f, DEC0201, DEC0208, DEC0212_Solaris); - } - - protected char decodeDouble(int byte1, int byte2) { - char c = super.decodeDouble(byte1, byte2); - if (c == UNMAPPABLE_DECODING) - return DEC0208_Solaris.decodeDouble(byte1 - 0x80, byte2 - 0x80); - return c; - } - } - - private static class Encoder extends EUC_JP.Encoder { - private static DoubleByte.Encoder ENC0208_Solaris = - (DoubleByte.Encoder)new JIS_X_0208_Solaris().newEncoder(); - - private static DoubleByte.Encoder ENC0212_Solaris = - (DoubleByte.Encoder)new JIS_X_0212_Solaris().newEncoder(); - - private Encoder(Charset cs) { - // The EUC_JP_Open has some interesting tweak for the - // encoding, so can't just pass the euc0208_solaris to - // the euc_jp. Have to override the encodeDouble() as - // showed below (mapping testing catches this). - // super(cs, 3.0f, 3.0f, ENC0201, ENC0208_Solaris, ENC0212_Solaris); - super(cs); - } - - protected int encodeDouble(char ch) { - int b = super.encodeDouble(ch); - if (b != UNMAPPABLE_ENCODING) - return b; - b = ENC0208_Solaris.encodeChar(ch); - if (b != UNMAPPABLE_ENCODING && b > 0x7500) { - return 0x8F8080 + ENC0212_Solaris.encodeChar(ch); - } - return b == UNMAPPABLE_ENCODING ? b : b + 0x8080; - - } - } -} --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/EUC_JP_Open.java.template 2015-02-16 10:41:44.000000000 -0800 @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2003, 2015, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package $PACKAGE$; + +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.CharsetEncoder; +import java.nio.charset.CoderResult; +import sun.nio.cs.DoubleByte; +import sun.nio.cs.HistoricallyNamedCharset; +import sun.nio.cs.*; +import static sun.nio.cs.CharsetMapping.*; + +public class EUC_JP_Open + extends Charset + implements HistoricallyNamedCharset +{ + public EUC_JP_Open() { + super("x-eucJP-Open", $ALIASES$); + } + + public String historicalName() { + return "EUC_JP_Solaris"; + } + + public boolean contains(Charset cs) { + return ((cs.name().equals("US-ASCII")) + || (cs instanceof JIS_X_0201) + || (cs instanceof EUC_JP)); + } + + public CharsetDecoder newDecoder() { + return new Decoder(this); + } + + public CharsetEncoder newEncoder() { + return new Encoder(this); + } + + private static class Decoder extends EUC_JP.Decoder { + private static DoubleByte.Decoder DEC0208_Solaris = + (DoubleByte.Decoder)new JIS_X_0208_Solaris().newDecoder(); + private static DoubleByte.Decoder DEC0212_Solaris = + (DoubleByte.Decoder)new JIS_X_0212_Solaris().newDecoder(); + + private Decoder(Charset cs) { + // JIS_X_0208_Solaris only has the "extra" mappings, it + // does not have the JIS_X_0208 entries + super(cs, 0.5f, 1.0f, DEC0201, DEC0208, DEC0212_Solaris); + } + + protected char decodeDouble(int byte1, int byte2) { + char c = super.decodeDouble(byte1, byte2); + if (c == UNMAPPABLE_DECODING) + return DEC0208_Solaris.decodeDouble(byte1 - 0x80, byte2 - 0x80); + return c; + } + } + + private static class Encoder extends EUC_JP.Encoder { + private static DoubleByte.Encoder ENC0208_Solaris = + (DoubleByte.Encoder)new JIS_X_0208_Solaris().newEncoder(); + + private static DoubleByte.Encoder ENC0212_Solaris = + (DoubleByte.Encoder)new JIS_X_0212_Solaris().newEncoder(); + + private Encoder(Charset cs) { + // The EUC_JP_Open has some interesting tweak for the + // encoding, so can't just pass the euc0208_solaris to + // the euc_jp. Have to override the encodeDouble() as + // showed below (mapping testing catches this). + // super(cs, 3.0f, 3.0f, ENC0201, ENC0208_Solaris, ENC0212_Solaris); + super(cs); + } + + protected int encodeDouble(char ch) { + int b = super.encodeDouble(ch); + if (b != UNMAPPABLE_ENCODING) + return b; + b = ENC0208_Solaris.encodeChar(ch); + if (b != UNMAPPABLE_ENCODING && b > 0x7500) { + return 0x8F8080 + ENC0212_Solaris.encodeChar(ch); + } + return b == UNMAPPABLE_ENCODING ? b : b + 0x8080; + + } + } +} --- old/src/jdk.charsets/share/classes/sun/nio/cs/ext/MS950_HKSCS_XP.java 2015-02-16 10:41:46.000000000 -0800 +++ /dev/null 2014-05-19 13:38:05.886368312 -0700 @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2002, 2010, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -package sun.nio.cs.ext; - -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.nio.charset.CharsetEncoder; -import sun.nio.cs.HistoricallyNamedCharset; -import static sun.nio.cs.CharsetMapping.*; - -public class MS950_HKSCS_XP extends Charset -{ - public MS950_HKSCS_XP() { - super("x-MS950-HKSCS-XP", ExtendedCharsets.aliasesFor("x-MS950-HKSCS-XP")); - } - - public boolean contains(Charset cs) { - return ((cs.name().equals("US-ASCII")) - || (cs instanceof MS950) - || (cs instanceof MS950_HKSCS_XP)); - } - - public CharsetDecoder newDecoder() { - return new Decoder(this); - } - - public CharsetEncoder newEncoder() { - return new Encoder(this); - } - - static class Decoder extends HKSCS.Decoder { - private static DoubleByte.Decoder ms950 = - (DoubleByte.Decoder)new MS950().newDecoder(); - - /* - * Note current decoder decodes 0x8BC2 --> U+F53A - * ie. maps to Unicode PUA. - * Unaccounted discrepancy between this mapping - * inferred from MS950/windows-950 and the published - * MS HKSCS mappings which maps 0x8BC2 --> U+5C22 - * a character defined with the Unified CJK block - */ - private static char[][] b2cBmp = new char[0x100][]; - static { - initb2c(b2cBmp, HKSCS_XPMapping.b2cBmpStr); - } - - public char decodeDoubleEx(int b1, int b2) { - return UNMAPPABLE_DECODING; - } - - private Decoder(Charset cs) { - super(cs, ms950, b2cBmp, null); - } - } - - private static class Encoder extends HKSCS.Encoder { - private static DoubleByte.Encoder ms950 = - (DoubleByte.Encoder)new MS950().newEncoder(); - - /* - * Note current encoder encodes U+F53A --> 0x8BC2 - * Published MS HKSCS mappings show - * U+5C22 <--> 0x8BC2 - */ - static char[][] c2bBmp = new char[0x100][]; - static { - initc2b(c2bBmp, HKSCS_XPMapping.b2cBmpStr, null); - } - - public int encodeSupp(int cp) { - return UNMAPPABLE_ENCODING; - } - - private Encoder(Charset cs) { - super(cs, ms950, c2bBmp, null); - } - } -} --- /dev/null 2014-05-19 13:38:05.886368312 -0700 +++ new/src/jdk.charsets/share/classes/sun/nio/cs/ext/MS950_HKSCS_XP.java.template 2015-02-16 10:41:46.000000000 -0800 @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2002, 2010, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +package $PACKAGE$; + +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.CharsetEncoder; +import sun.nio.cs.DoubleByte; +import sun.nio.cs.HKSCS; +import sun.nio.cs.HistoricallyNamedCharset; +import static sun.nio.cs.CharsetMapping.*; + +public class MS950_HKSCS_XP extends Charset +{ + public MS950_HKSCS_XP() { + super("x-MS950-HKSCS-XP", $ALIASES$); + } + + public boolean contains(Charset cs) { + return ((cs.name().equals("US-ASCII")) + || (cs instanceof MS950) + || (cs instanceof MS950_HKSCS_XP)); + } + + public CharsetDecoder newDecoder() { + return new Decoder(this); + } + + public CharsetEncoder newEncoder() { + return new Encoder(this); + } + + static class Decoder extends HKSCS.Decoder { + private static DoubleByte.Decoder ms950 = + (DoubleByte.Decoder)new MS950().newDecoder(); + + /* + * Note current decoder decodes 0x8BC2 --> U+F53A + * ie. maps to Unicode PUA. + * Unaccounted discrepancy between this mapping + * inferred from MS950/windows-950 and the published + * MS HKSCS mappings which maps 0x8BC2 --> U+5C22 + * a character defined with the Unified CJK block + */ + private static char[][] b2cBmp = new char[0x100][]; + static { + initb2c(b2cBmp, HKSCS_XPMapping.b2cBmpStr); + } + + public char decodeDoubleEx(int b1, int b2) { + return UNMAPPABLE_DECODING; + } + + private Decoder(Charset cs) { + super(cs, ms950, b2cBmp, null); + } + } + + private static class Encoder extends HKSCS.Encoder { + private static DoubleByte.Encoder ms950 = + (DoubleByte.Encoder)new MS950().newEncoder(); + + /* + * Note current encoder encodes U+F53A --> 0x8BC2 + * Published MS HKSCS mappings show + * U+5C22 <--> 0x8BC2 + */ + static char[][] c2bBmp = new char[0x100][]; + static { + initc2b(c2bBmp, HKSCS_XPMapping.b2cBmpStr, null); + } + + public int encodeSupp(int cp) { + return UNMAPPABLE_ENCODING; + } + + private Encoder(Charset cs) { + super(cs, ms950, c2bBmp, null); + } + } +} --- old/src/java.desktop/share/classes/sun/awt/HKSCS.java 2015-02-16 10:41:47.000000000 -0800 +++ new/src/java.desktop/share/classes/sun/awt/HKSCS.java 2015-02-16 10:41:47.000000000 -0800 @@ -34,11 +34,21 @@ ExtendedCharsets class, because if we want to have a public HKSCS, it probably should be HKSCS_2001 not HKSCS. */ -public class HKSCS extends sun.nio.cs.ext.MS950_HKSCS_XP { +public class HKSCS extends Charset { + private static Charset cs = Charset.forName("x-MS950-HKSCS-XP"); + public HKSCS () { - super(); + super("HKSCS", null); } public boolean contains(Charset cs) { return (cs instanceof HKSCS); } + + public CharsetDecoder newDecoder() { + return cs.newDecoder(); + } + + public CharsetEncoder newEncoder() { + return cs.newEncoder(); + } } --- old/src/java.desktop/unix/classes/sun/awt/motif/X11GB2312.java 2015-02-16 10:41:49.000000000 -0800 +++ new/src/java.desktop/unix/classes/sun/awt/motif/X11GB2312.java 2015-02-16 10:41:48.000000000 -0800 @@ -28,6 +28,7 @@ import java.nio.CharBuffer; import java.nio.ByteBuffer; import java.nio.charset.*; +import sun.nio.cs.*; import sun.nio.cs.ext.*; import static sun.nio.cs.CharsetMapping.*; --- old/src/java.desktop/unix/classes/sun/awt/motif/X11GBK.java 2015-02-16 10:41:50.000000000 -0800 +++ new/src/java.desktop/unix/classes/sun/awt/motif/X11GBK.java 2015-02-16 10:41:49.000000000 -0800 @@ -26,6 +26,7 @@ package sun.awt.motif; import java.nio.charset.*; +import sun.nio.cs.*; import sun.nio.cs.ext.*; import static sun.nio.cs.CharsetMapping.*; --- old/src/java.desktop/unix/classes/sun/awt/motif/X11JIS0201.java 2015-02-16 10:41:51.000000000 -0800 +++ new/src/java.desktop/unix/classes/sun/awt/motif/X11JIS0201.java 2015-02-16 10:41:51.000000000 -0800 @@ -29,7 +29,7 @@ import java.nio.CharBuffer; import java.nio.charset.*; import sun.nio.cs.*; -import sun.nio.cs.ext.JIS_X_0201; +import sun.nio.cs.ext.*; import static sun.nio.cs.CharsetMapping.*; public class X11JIS0201 extends Charset { --- old/src/java.desktop/unix/classes/sun/awt/motif/X11JIS0208.java 2015-02-16 10:41:53.000000000 -0800 +++ new/src/java.desktop/unix/classes/sun/awt/motif/X11JIS0208.java 2015-02-16 10:41:52.000000000 -0800 @@ -28,7 +28,8 @@ import java.nio.charset.Charset; import java.nio.charset.CharsetEncoder; import java.nio.charset.CharsetDecoder; -import sun.nio.cs.ext.JIS_X_0208; +import sun.nio.cs.*; +import sun.nio.cs.ext.*; public class X11JIS0208 extends Charset { --- old/src/java.desktop/unix/classes/sun/awt/motif/X11JIS0212.java 2015-02-16 10:41:54.000000000 -0800 +++ new/src/java.desktop/unix/classes/sun/awt/motif/X11JIS0212.java 2015-02-16 10:41:53.000000000 -0800 @@ -28,7 +28,8 @@ import java.nio.charset.Charset; import java.nio.charset.CharsetEncoder; import java.nio.charset.CharsetDecoder; -import sun.nio.cs.ext.JIS_X_0212; +import sun.nio.cs.*; +import sun.nio.cs.ext.*; public class X11JIS0212 extends Charset { private static Charset jis0212 = new JIS_X_0212(); --- old/src/java.desktop/unix/classes/sun/awt/motif/X11KSC5601.java 2015-02-16 10:41:55.000000000 -0800 +++ new/src/java.desktop/unix/classes/sun/awt/motif/X11KSC5601.java 2015-02-16 10:41:54.000000000 -0800 @@ -28,6 +28,7 @@ import java.nio.CharBuffer; import java.nio.ByteBuffer; import java.nio.charset.*; +import sun.nio.cs.*; import sun.nio.cs.ext.*; import static sun.nio.cs.CharsetMapping.*; --- old/test/java/nio/charset/Charset/NIOCharsetAvailabilityTest.java 2015-02-16 10:41:56.000000000 -0800 +++ new/test/java/nio/charset/Charset/NIOCharsetAvailabilityTest.java 2015-02-16 10:41:56.000000000 -0800 @@ -65,11 +65,17 @@ charsets.remove(Class.forName("sun.nio.cs.ext.ISO2022")); charsets.remove(Class.forName("sun.nio.cs.ext.ISO2022_CN_GB")); charsets.remove(Class.forName("sun.nio.cs.ext.ISO2022_CN_CNS")); - charsets.remove(Class.forName("sun.nio.cs.ext.JIS_X_0208_Solaris")); charsets.remove(Class.forName("sun.nio.cs.ext.JIS_X_0208_MS932")); charsets.remove(Class.forName("sun.nio.cs.ext.JIS_X_0212_MS5022X")); - charsets.remove(Class.forName("sun.nio.cs.ext.JIS_X_0212_Solaris")); charsets.remove(Class.forName("sun.nio.cs.ext.JIS_X_0208_MS5022X")); + try { + charsets.remove(Class.forName("sun.nio.cs.ext.JIS_X_0208_Solaris")); + charsets.remove(Class.forName("sun.nio.cs.ext.JIS_X_0212_Solaris")); + } catch (ClassNotFoundException x) { + // these two might be moved into stdcs + charsets.remove(Class.forName("sun.nio.cs.JIS_X_0208_Solaris")); + charsets.remove(Class.forName("sun.nio.cs.JIS_X_0212_Solaris")); + } // report the charsets that are implemented but not available iter = charsets.iterator();