Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java
38919 views
/*1* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.nio.cs.ext;2627import java.lang.ref.SoftReference;28import java.nio.charset.Charset;29import java.nio.charset.spi.CharsetProvider;30import sun.nio.cs.AbstractCharsetProvider;31import java.security.AccessController;32import sun.security.action.GetPropertyAction;333435/**36* Provider for extended charsets.37*/3839public class ExtendedCharsets40extends AbstractCharsetProvider41{4243static volatile ExtendedCharsets instance = null;4445public ExtendedCharsets() {4647super("sun.nio.cs.ext"); // identify provider pkg name.4849// Traditional Chinese5051charset("Big5", "Big5",52new String[] {53// IANA aliases54"csBig5"55});5657charset("x-MS950-HKSCS-XP", "MS950_HKSCS_XP",58new String[] {59"MS950_HKSCS_XP" // JDK historical;60});6162charset("x-MS950-HKSCS", "MS950_HKSCS",63new String[] {64// IANA aliases65"MS950_HKSCS" // JDK historical;66});6768charset("x-windows-950", "MS950",69new String[] {70"ms950", // JDK historical71"windows-950"72});7374charset("x-windows-874", "MS874",75new String[] {76"ms874", // JDK historical77"ms-874",78"windows-874" });7980charset("x-EUC-TW", "EUC_TW",81new String[] {82"euc_tw", // JDK historical83"euctw",84"cns11643",85"EUC-TW"86});8788charset("Big5-HKSCS", "Big5_HKSCS",89new String[] {90"Big5_HKSCS", // JDK historical91"big5hk",92"big5-hkscs",93"big5hkscs" // Linux alias94});9596charset("x-Big5-HKSCS-2001", "Big5_HKSCS_2001",97new String[] {98"Big5_HKSCS_2001",99"big5hk-2001",100"big5-hkscs-2001",101"big5-hkscs:unicode3.0",102"big5hkscs-2001",103});104105charset("x-Big5-Solaris", "Big5_Solaris",106new String[] {107"Big5_Solaris", // JDK historical108});109110// Simplified Chinese111charset("GBK", "GBK",112new String[] {113"windows-936",114"CP936"115});116117charset("GB18030", "GB18030",118new String[] {119"gb18030-2000"120});121122charset("GB2312", "EUC_CN",123new String[] {124// IANA aliases125"gb2312",126"gb2312-80",127"gb2312-1980",128"euc-cn",129"euccn",130"x-EUC-CN", // 1.4 compatibility131"EUC_CN" //JDK historical132});133134charset("x-mswin-936", "MS936",135new String[] {136"ms936", // historical137// IANA aliases138"ms_936"139});140141// The definition of this charset may be overridden by the init method,142// below, if the sun.nio.cs.map property is defined.143//144charset("Shift_JIS", "SJIS",145new String[] {146// IANA aliases147"sjis", // historical148"shift_jis",149"shift-jis",150"ms_kanji",151"x-sjis",152"csShiftJIS"153});154155// The definition of this charset may be overridden by the init method,156// below, if the sun.nio.cs.map property is defined.157//158charset("windows-31j", "MS932",159new String[] {160"MS932", // JDK historical161"windows-932",162"csWindows31J"163});164165charset("JIS_X0201", "JIS_X_0201",166new String[] {167"JIS0201", // JDK historical168// IANA aliases169"JIS_X0201",170"X0201",171"csHalfWidthKatakana"172});173174charset("x-JIS0208", "JIS_X_0208",175new String[] {176"JIS0208", // JDK historical177// IANA aliases178"JIS_C6226-1983",179"iso-ir-87",180"x0208",181"JIS_X0208-1983",182"csISO87JISX0208"183});184185charset("JIS_X0212-1990", "JIS_X_0212",186new String[] {187"JIS0212", // JDK historical188// IANA aliases189"jis_x0212-1990",190"x0212",191"iso-ir-159",192"csISO159JISX02121990"193});194195charset("x-SJIS_0213", "SJIS_0213",196new String[] {197"sjis-0213",198"sjis_0213",199"sjis:2004",200"sjis_0213:2004",201"shift_jis_0213:2004",202"shift_jis:2004"203});204205charset("x-MS932_0213", "MS932_0213",206new String[] {207"MS932-0213",208"MS932_0213",209"MS932:2004",210"windows-932-0213",211"windows-932:2004"212});213214charset("EUC-JP", "EUC_JP",215new String[] {216"euc_jp", // JDK historical217// IANA aliases218"eucjis",219"eucjp",220"Extended_UNIX_Code_Packed_Format_for_Japanese",221"csEUCPkdFmtjapanese",222"x-euc-jp",223"x-eucjp"224});225226charset("x-euc-jp-linux", "EUC_JP_LINUX",227new String[] {228"euc_jp_linux", // JDK historical229"euc-jp-linux"230});231232charset("x-eucjp-open", "EUC_JP_Open",233new String[] {234"EUC_JP_Solaris", // JDK historical235"eucJP-open"236});237238charset("x-PCK", "PCK",239new String[] {240// IANA aliases241"pck" // historical242});243244charset("ISO-2022-JP", "ISO2022_JP",245new String[] {246// IANA aliases247"iso2022jp", // historical248"jis",249"csISO2022JP",250"jis_encoding",251"csjisencoding"252});253254charset("ISO-2022-JP-2", "ISO2022_JP_2",255new String[] {256// IANA aliases257"csISO2022JP2",258"iso2022jp2"259});260261charset("x-windows-50221", "MS50221",262new String[] {263"ms50221", // historical264"cp50221",265});266267charset("x-windows-50220", "MS50220",268new String[] {269"ms50220", // historical270"cp50220",271});272273charset("x-windows-iso2022jp", "MSISO2022JP",274new String[] {275"windows-iso2022jp", // historical276});277278charset("x-JISAutoDetect", "JISAutoDetect",279new String[] {280"JISAutoDetect" // historical281});282283// Korean284charset("EUC-KR", "EUC_KR",285new String[] {286"euc_kr", // JDK historical287// IANA aliases288"ksc5601",289"euckr",290"ks_c_5601-1987",291"ksc5601-1987",292"ksc5601_1987",293"ksc_5601",294"csEUCKR",295"5601"296});297298charset("x-windows-949", "MS949",299new String[] {300"ms949", // JDK historical301"windows949",302"windows-949",303// IANA aliases304"ms_949"305});306307charset("x-Johab", "Johab",308new String[] {309"ksc5601-1992",310"ksc5601_1992",311"ms1361",312"johab" // JDK historical313});314315charset("ISO-2022-KR", "ISO2022_KR",316new String[] {317"ISO2022KR", // JDK historical318"csISO2022KR"319});320321charset("ISO-2022-CN", "ISO2022_CN",322new String[] {323"ISO2022CN", // JDK historical324"csISO2022CN"325});326327charset("x-ISO-2022-CN-CNS", "ISO2022_CN_CNS",328new String[] {329"ISO2022CN_CNS", // JDK historical330"ISO-2022-CN-CNS"331});332333charset("x-ISO-2022-CN-GB", "ISO2022_CN_GB",334new String[] {335"ISO2022CN_GB", // JDK historical336"ISO-2022-CN-GB"337});338339charset("x-ISCII91", "ISCII91",340new String[] {341"iscii",342"ST_SEV_358-88",343"iso-ir-153",344"csISO153GOST1976874",345"ISCII91" // JDK historical346});347348charset("ISO-8859-3", "ISO_8859_3",349new String[] {350"iso8859_3", // JDK historical351"8859_3",352"ISO_8859-3:1988",353"iso-ir-109",354"ISO_8859-3",355"ISO8859-3",356"latin3",357"l3",358"ibm913",359"ibm-913",360"cp913",361"913",362"csISOLatin3"363});364365charset("ISO-8859-6", "ISO_8859_6",366new String[] {367"iso8859_6", // JDK historical368"8859_6",369"iso-ir-127",370"ISO_8859-6",371"ISO_8859-6:1987",372"ISO8859-6",373"ECMA-114",374"ASMO-708",375"arabic",376"ibm1089",377"ibm-1089",378"cp1089",379"1089",380"csISOLatinArabic"381});382383charset("ISO-8859-8", "ISO_8859_8",384new String[] {385"iso8859_8", // JDK historical386"8859_8",387"iso-ir-138",388"ISO_8859-8",389"ISO_8859-8:1988",390"ISO8859-8",391"cp916",392"916",393"ibm916",394"ibm-916",395"hebrew",396"csISOLatinHebrew"397});398399charset("x-ISO-8859-11", "ISO_8859_11",400new String[] {401"iso-8859-11",402"iso8859_11"403});404405charset("TIS-620", "TIS_620",406new String[] {407"tis620", // JDK historical408"tis620.2533"409});410411// Various Microsoft Windows international codepages412413charset("windows-1255", "MS1255",414new String[] {415"cp1255" // JDK historical416});417418charset("windows-1256", "MS1256",419new String[] {420"cp1256" // JDK historical421});422423charset("windows-1258", "MS1258",424new String[] {425"cp1258" // JDK historical426});427428// IBM & PC/MSDOS encodings429430charset("x-IBM942", "IBM942",431new String[] {432"cp942", // JDK historical433"ibm942",434"ibm-942",435"942"436});437438charset("x-IBM942C", "IBM942C",439new String[] {440"cp942C", // JDK historical441"ibm942C",442"ibm-942C",443"942C"444});445446charset("x-IBM943", "IBM943",447new String[] {448"cp943", // JDK historical449"ibm943",450"ibm-943",451"943"452});453454charset("x-IBM943C", "IBM943C",455new String[] {456"cp943C", // JDK historical457"ibm943C",458"ibm-943C",459"943C"460});461462charset("x-IBM948", "IBM948",463new String[] {464"cp948", // JDK historical465"ibm948",466"ibm-948",467"948"468});469470charset("x-IBM950", "IBM950",471new String[] {472"cp950", // JDK historical473"ibm950",474"ibm-950",475"950"476});477478charset("x-IBM930", "IBM930",479new String[] {480"cp930", // JDK historical481"ibm930",482"ibm-930",483"930"484});485486charset("x-IBM935", "IBM935",487new String[] {488"cp935", // JDK historical489"ibm935",490"ibm-935",491"935"492});493494charset("x-IBM937", "IBM937",495new String[] {496"cp937", // JDK historical497"ibm937",498"ibm-937",499"937"500});501502charset("x-IBM856", "IBM856",503new String[] {504"cp856", // JDK historical505"ibm-856",506"ibm856",507"856"508});509510charset("IBM860", "IBM860",511new String[] {512"cp860", // JDK historical513"ibm860",514"ibm-860",515"860",516"csIBM860"517});518charset("IBM861", "IBM861",519new String[] {520"cp861", // JDK historical521"ibm861",522"ibm-861",523"861",524"csIBM861",525"cp-is"526});527528charset("IBM863", "IBM863",529new String[] {530"cp863", // JDK historical531"ibm863",532"ibm-863",533"863",534"csIBM863"535});536537charset("IBM864", "IBM864",538new String[] {539"cp864", // JDK historical540"ibm864",541"ibm-864",542"864",543"csIBM864"544});545546charset("IBM865", "IBM865",547new String[] {548"cp865", // JDK historical549"ibm865",550"ibm-865",551"865",552"csIBM865"553});554555charset("IBM868", "IBM868",556new String[] {557"cp868", // JDK historical558"ibm868",559"ibm-868",560"868",561"cp-ar",562"csIBM868"563});564565charset("IBM869", "IBM869",566new String[] {567"cp869", // JDK historical568"ibm869",569"ibm-869",570"869",571"cp-gr",572"csIBM869"573});574575charset("x-IBM921", "IBM921",576new String[] {577"cp921", // JDK historical578"ibm921",579"ibm-921",580"921"581});582583charset("x-IBM1006", "IBM1006",584new String[] {585"cp1006", // JDK historical586"ibm1006",587"ibm-1006",588"1006"589});590591charset("x-IBM1046", "IBM1046",592new String[] {593"cp1046", // JDK historical594"ibm1046",595"ibm-1046",596"1046"597});598599charset("IBM1047", "IBM1047",600new String[] {601"cp1047", // JDK historical602"ibm-1047",603"1047"604});605606charset("x-IBM1098", "IBM1098",607new String[] {608"cp1098", // JDK historical609"ibm1098",610"ibm-1098",611"1098",612});613614charset("IBM037", "IBM037",615new String[] {616"cp037", // JDK historical617"ibm037",618"ebcdic-cp-us",619"ebcdic-cp-ca",620"ebcdic-cp-wt",621"ebcdic-cp-nl",622"csIBM037",623"cs-ebcdic-cp-us",624"cs-ebcdic-cp-ca",625"cs-ebcdic-cp-wt",626"cs-ebcdic-cp-nl",627"ibm-037",628"ibm-37",629"cpibm37",630"037"631});632633charset("x-IBM1025", "IBM1025",634new String[] {635"cp1025", // JDK historical636"ibm1025",637"ibm-1025",638"1025"639});640641charset("IBM1026", "IBM1026",642new String[] {643"cp1026", // JDK historical644"ibm1026",645"ibm-1026",646"1026"647});648649charset("x-IBM1112", "IBM1112",650new String[] {651"cp1112", // JDK historical652"ibm1112",653"ibm-1112",654"1112"655});656657charset("x-IBM1122", "IBM1122",658new String[] {659"cp1122", // JDK historical660"ibm1122",661"ibm-1122",662"1122"663});664665charset("x-IBM1123", "IBM1123",666new String[] {667"cp1123", // JDK historical668"ibm1123",669"ibm-1123",670"1123"671});672673charset("x-IBM1124", "IBM1124",674new String[] {675"cp1124", // JDK historical676"ibm1124",677"ibm-1124",678"1124"679});680681charset("x-IBM1364", "IBM1364",682new String[] {683"cp1364",684"ibm1364",685"ibm-1364",686"1364"687});688689charset("IBM273", "IBM273",690new String[] {691"cp273", // JDK historical692"ibm273",693"ibm-273",694"273"695});696697charset("IBM277", "IBM277",698new String[] {699"cp277", // JDK historical700"ibm277",701"ibm-277",702"277"703});704705charset("IBM278", "IBM278",706new String[] {707"cp278", // JDK historical708"ibm278",709"ibm-278",710"278",711"ebcdic-sv",712"ebcdic-cp-se",713"csIBM278"714});715716charset("IBM280", "IBM280",717new String[] {718"cp280", // JDK historical719"ibm280",720"ibm-280",721"280"722});723724charset("IBM284", "IBM284",725new String[] {726"cp284", // JDK historical727"ibm284",728"ibm-284",729"284",730"csIBM284",731"cpibm284"732});733734charset("IBM285", "IBM285",735new String[] {736"cp285", // JDK historical737"ibm285",738"ibm-285",739"285",740"ebcdic-cp-gb",741"ebcdic-gb",742"csIBM285",743"cpibm285"744});745746charset("IBM297", "IBM297",747new String[] {748"cp297", // JDK historical749"ibm297",750"ibm-297",751"297",752"ebcdic-cp-fr",753"cpibm297",754"csIBM297",755});756757charset("IBM420", "IBM420",758new String[] {759"cp420", // JDK historical760"ibm420",761"ibm-420",762"ebcdic-cp-ar1",763"420",764"csIBM420"765});766767charset("IBM424", "IBM424",768new String[] {769"cp424", // JDK historical770"ibm424",771"ibm-424",772"424",773"ebcdic-cp-he",774"csIBM424"775});776777charset("IBM500", "IBM500",778new String[] {779"cp500", // JDK historical780"ibm500",781"ibm-500",782"500",783"ebcdic-cp-ch",784"ebcdic-cp-bh",785"csIBM500"786});787788charset("x-IBM833", "IBM833",789new String[] {790"cp833",791"ibm833",792"ibm-833"793});794795//EBCDIC DBCS-only Korean796charset("x-IBM834", "IBM834",797new String[] {798"cp834",799"ibm834",800"834",801"ibm-834"802});803804805charset("IBM-Thai", "IBM838",806new String[] {807"cp838", // JDK historical808"ibm838",809"ibm-838",810"838"811});812813charset("IBM870", "IBM870",814new String[] {815"cp870", // JDK historical816"ibm870",817"ibm-870",818"870",819"ebcdic-cp-roece",820"ebcdic-cp-yu",821"csIBM870"822});823824charset("IBM871", "IBM871",825new String[] {826"cp871", // JDK historical827"ibm871",828"ibm-871",829"871",830"ebcdic-cp-is",831"csIBM871"832});833834charset("x-IBM875", "IBM875",835new String[] {836"cp875", // JDK historical837"ibm875",838"ibm-875",839"875"840});841842charset("IBM918", "IBM918",843new String[] {844"cp918", // JDK historical845"ibm-918",846"918",847"ebcdic-cp-ar2"848});849850charset("x-IBM922", "IBM922",851new String[] {852"cp922", // JDK historical853"ibm922",854"ibm-922",855"922"856});857858charset("x-IBM1097", "IBM1097",859new String[] {860"cp1097", // JDK historical861"ibm1097",862"ibm-1097",863"1097"864});865866charset("x-IBM949", "IBM949",867new String[] {868"cp949", // JDK historical869"ibm949",870"ibm-949",871"949"872});873874charset("x-IBM949C", "IBM949C",875new String[] {876"cp949C", // JDK historical877"ibm949C",878"ibm-949C",879"949C"880});881882charset("x-IBM939", "IBM939",883new String[] {884"cp939", // JDK historical885"ibm939",886"ibm-939",887"939"888});889890charset("x-IBM933", "IBM933",891new String[] {892"cp933", // JDK historical893"ibm933",894"ibm-933",895"933"896});897898charset("x-IBM1381", "IBM1381",899new String[] {900"cp1381", // JDK historical901"ibm1381",902"ibm-1381",903"1381"904});905906charset("x-IBM1383", "IBM1383",907new String[] {908"cp1383", // JDK historical909"ibm1383",910"ibm-1383",911"1383"912});913914charset("x-IBM970", "IBM970",915new String[] {916"cp970", // JDK historical917"ibm970",918"ibm-970",919"ibm-eucKR",920"970"921});922923charset("x-IBM964", "IBM964",924new String[] {925"cp964", // JDK historical926"ibm964",927"ibm-964",928"964"929});930931charset("x-IBM33722", "IBM33722",932new String[] {933"cp33722", // JDK historical934"ibm33722",935"ibm-33722",936"ibm-5050", // from IBM alias list937"ibm-33722_vascii_vpua", // from IBM alias list938"33722"939});940941charset("IBM01140", "IBM1140",942new String[] {943"cp1140", // JDK historical944"ccsid01140",945"cp01140",946"1140",947"ebcdic-us-037+euro"948});949950charset("IBM01141", "IBM1141",951new String[] {952"cp1141", // JDK historical953"ccsid01141",954"cp01141",955"1141",956"ebcdic-de-273+euro"957});958959charset("IBM01142", "IBM1142",960new String[] {961"cp1142", // JDK historical962"ccsid01142",963"cp01142",964"1142",965"ebcdic-no-277+euro",966"ebcdic-dk-277+euro"967});968969charset("IBM01143", "IBM1143",970new String[] {971"cp1143", // JDK historical972"ccsid01143",973"cp01143",974"1143",975"ebcdic-fi-278+euro",976"ebcdic-se-278+euro"977});978979charset("IBM01144", "IBM1144",980new String[] {981"cp1144", // JDK historical982"ccsid01144",983"cp01144",984"1144",985"ebcdic-it-280+euro"986});987988charset("IBM01145", "IBM1145",989new String[] {990"cp1145", // JDK historical991"ccsid01145",992"cp01145",993"1145",994"ebcdic-es-284+euro"995});996997charset("IBM01146", "IBM1146",998new String[] {999"cp1146", // JDK historical1000"ccsid01146",1001"cp01146",1002"1146",1003"ebcdic-gb-285+euro"1004});10051006charset("IBM01147", "IBM1147",1007new String[] {1008"cp1147", // JDK historical1009"ccsid01147",1010"cp01147",1011"1147",1012"ebcdic-fr-277+euro"1013});10141015charset("IBM01148", "IBM1148",1016new String[] {1017"cp1148", // JDK historical1018"ccsid01148",1019"cp01148",1020"1148",1021"ebcdic-international-500+euro"1022});10231024charset("IBM01149", "IBM1149",1025new String[] {1026"cp1149", // JDK historical1027"ccsid01149",1028"cp01149",1029"1149",1030"ebcdic-s-871+euro"1031});10321033charset("x-IBM1166", "IBM1166",1034new String[] {1035"cp1166", // JDK historical1036"ibm1166",1037"ibm-1166",1038"1166"1039});10401041charset("IBM290", "IBM290",1042new String[] {1043"cp290",1044"ibm290",1045"ibm-290",1046"csIBM290",1047"EBCDIC-JP-kana",1048"290"1049});10501051charset("x-IBM300", "IBM300",1052new String[] {1053"cp300",1054"ibm300",1055"ibm-300",1056"300"1057});10581059// Macintosh MacOS/Apple char encodingd106010611062charset("x-MacRoman", "MacRoman",1063new String[] {1064"MacRoman" // JDK historical1065});10661067charset("x-MacCentralEurope", "MacCentralEurope",1068new String[] {1069"MacCentralEurope" // JDK historical1070});10711072charset("x-MacCroatian", "MacCroatian",1073new String[] {1074"MacCroatian" // JDK historical1075});107610771078charset("x-MacGreek", "MacGreek",1079new String[] {1080"MacGreek" // JDK historical1081});10821083charset("x-MacCyrillic", "MacCyrillic",1084new String[] {1085"MacCyrillic" // JDK historical1086});10871088charset("x-MacUkraine", "MacUkraine",1089new String[] {1090"MacUkraine" // JDK historical1091});10921093charset("x-MacTurkish", "MacTurkish",1094new String[] {1095"MacTurkish" // JDK historical1096});10971098charset("x-MacArabic", "MacArabic",1099new String[] {1100"MacArabic" // JDK historical1101});11021103charset("x-MacHebrew", "MacHebrew",1104new String[] {1105"MacHebrew" // JDK historical1106});11071108charset("x-MacIceland", "MacIceland",1109new String[] {1110"MacIceland" // JDK historical1111});11121113charset("x-MacRomania", "MacRomania",1114new String[] {1115"MacRomania" // JDK historical1116});11171118charset("x-MacThai", "MacThai",1119new String[] {1120"MacThai" // JDK historical1121});11221123charset("x-MacSymbol", "MacSymbol",1124new String[] {1125"MacSymbol" // JDK historical1126});11271128charset("x-MacDingbat", "MacDingbat",1129new String[] {1130"MacDingbat" // JDK historical1131});11321133instance = this;11341135}11361137private boolean initialized = false;11381139// If the sun.nio.cs.map property is defined on the command line we won't1140// see it in the system-properties table until after the charset subsystem1141// has been initialized. We therefore delay the effect of this property1142// until after the JRE has completely booted.1143//1144// At the moment following values for this property are supported, property1145// value string is case insensitive.1146//1147// (1)"Windows-31J/Shift_JIS"1148// In 1.4.1 we added a correct implementation of the Shift_JIS charset1149// but in previous releases this charset name had been treated as an alias1150// for Windows-31J, aka MS932. Users who have existing code that depends1151// upon this alias can restore the previous behavior by defining this1152// property to have this value.1153//1154// (2)"x-windows-50221/ISO-2022-JP"1155// "x-windows-50220/ISO-2022-JP"1156// "x-windows-iso2022jp/ISO-2022-JP"1157// The charset ISO-2022-JP is a "standard based" implementation by default,1158// which supports ASCII, JIS_X_0201 and JIS_X_0208 mappings based encoding1159// and decoding only.1160// There are three Microsoft iso-2022-jp variants, namely x-windows-50220,1161// x-windows-50221 and x-windows-iso2022jp which behaves "slightly" differently1162// compared to the "standard based" implementation. See ISO2022_JP.java for1163// detailed description. Users who prefer the behavior of MS iso-2022-jp1164// variants should use these names explicitly instead of using "ISO-2022-JP"1165// and its aliases. However for those who need the ISO-2022-JP charset behaves1166// exactly the same as MS variants do, above properties can be defined to1167// switch.1168//1169// If we need to define other charset-alias mappings in the future then1170// this property could be further extended, the general idea being that its1171// value should be of the form1172//1173// new-charset-1/old-charset-1,new-charset-2/old-charset-2,...1174//1175// where each charset named to the left of a slash is intended to replace1176// (most) uses of the charset named to the right of the slash.1177//1178protected void init() {1179if (initialized)1180return;1181if (!sun.misc.VM.isBooted())1182return;11831184String map = AccessController.doPrivileged(1185new GetPropertyAction("sun.nio.cs.map"));1186boolean sjisIsMS932 = false;1187boolean iso2022jpIsMS50221 = false;1188boolean iso2022jpIsMS50220 = false;1189boolean iso2022jpIsMSISO2022JP = false;1190if (map != null) {1191String[] maps = map.split(",");1192for (int i = 0; i < maps.length; i++) {1193if (maps[i].equalsIgnoreCase("Windows-31J/Shift_JIS")) {1194sjisIsMS932 = true;1195} else if (maps[i].equalsIgnoreCase("x-windows-50221/ISO-2022-JP")) {1196iso2022jpIsMS50221 = true;1197} else if (maps[i].equalsIgnoreCase("x-windows-50220/ISO-2022-JP")) {1198iso2022jpIsMS50220 = true;1199} else if (maps[i].equalsIgnoreCase("x-windows-iso2022jp/ISO-2022-JP")) {1200iso2022jpIsMSISO2022JP = true;1201}1202}1203}1204if (sjisIsMS932) {1205deleteCharset("Shift_JIS",1206new String[] {1207// IANA aliases1208"sjis", // historical1209"shift_jis",1210"shift-jis",1211"ms_kanji",1212"x-sjis",1213"csShiftJIS"1214});1215deleteCharset("windows-31j",1216new String[] {1217"MS932", // JDK historical1218"windows-932",1219"csWindows31J"1220});1221charset("Shift_JIS", "SJIS",1222new String[] {1223// IANA aliases1224"sjis" // JDK historical1225});1226charset("windows-31j", "MS932",1227new String[] {1228"MS932", // JDK historical1229"windows-932",1230"csWindows31J",1231"shift-jis",1232"ms_kanji",1233"x-sjis",1234"csShiftJIS",1235// This alias takes precedence over the actual1236// Shift_JIS charset itself since aliases are always1237// resolved first, before looking up canonical names.1238"shift_jis"1239});1240}1241if (iso2022jpIsMS50221 ||1242iso2022jpIsMS50220 ||1243iso2022jpIsMSISO2022JP) {1244deleteCharset("ISO-2022-JP",1245new String[] {1246"iso2022jp",1247"jis",1248"csISO2022JP",1249"jis_encoding",1250"csjisencoding"1251});1252if (iso2022jpIsMS50221) {1253deleteCharset("x-windows-50221",1254new String[] {1255"cp50221",1256"ms50221"1257});1258charset("x-windows-50221", "MS50221",1259new String[] {1260"cp50221",1261"ms50221",1262"iso-2022-jp",1263"iso2022jp",1264"jis",1265"csISO2022JP",1266"jis_encoding",1267"csjisencoding"1268});1269} else if (iso2022jpIsMS50220) {1270deleteCharset("x-windows-50220",1271new String[] {1272"cp50220",1273"ms50220"1274});1275charset("x-windows-50220", "MS50220",1276new String[] {1277"cp50220",1278"ms50220",1279"iso-2022-jp",1280"iso2022jp",1281"jis",1282"csISO2022JP",1283"jis_encoding",1284"csjisencoding"1285});1286} else {1287deleteCharset("x-windows-iso2022jp",1288new String[] {1289"windows-iso2022jp"1290});1291charset("x-windows-iso2022jp", "MSISO2022JP",1292new String[] {1293"windows-iso2022jp",1294"iso-2022-jp",1295"iso2022jp",1296"jis",1297"csISO2022JP",1298"jis_encoding",1299"csjisencoding"1300});130113021303}1304}1305String osName = AccessController.doPrivileged(1306new GetPropertyAction("os.name"));1307if ("SunOS".equals(osName) || "Linux".equals(osName) || "AIX".equals(osName)1308|| osName.contains("OS X")) {1309charset("x-COMPOUND_TEXT", "COMPOUND_TEXT",1310new String[] {1311"COMPOUND_TEXT", // JDK historical1312"x11-compound_text",1313"x-compound-text"1314});1315}1316initialized = true;1317}13181319public static String[] aliasesFor(String charsetName) {1320if (instance == null)1321return null;1322return instance.aliases(charsetName);1323}1324}132513261327