1 /*
   2  * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.nio.cs.ext;
  27 
  28 import java.lang.ref.SoftReference;
  29 import java.nio.charset.Charset;
  30 import java.nio.charset.spi.CharsetProvider;
  31 import sun.nio.cs.AbstractCharsetProvider;
  32 import java.security.AccessController;
  33 import sun.security.action.GetPropertyAction;
  34 
  35 
  36 /**
  37  * Provider for extended charsets.
  38  */
  39 
  40 public class ExtendedCharsets
  41     extends AbstractCharsetProvider
  42 {
  43 
  44     static volatile ExtendedCharsets instance = null;
  45 
  46     public ExtendedCharsets() {
  47 
  48         super("sun.nio.cs.ext");  // identify provider pkg name.
  49 
  50         // Traditional Chinese
  51 
  52         charset("Big5", "Big5",
  53                 new String[] {
  54                     // IANA aliases
  55                     "csBig5"
  56                 });
  57 
  58         charset("x-MS950-HKSCS-XP", "MS950_HKSCS_XP",
  59                 new String[] {
  60                     "MS950_HKSCS_XP"  // JDK historical;
  61                 });
  62 
  63         charset("x-MS950-HKSCS", "MS950_HKSCS",
  64                 new String[] {
  65                     // IANA aliases
  66                     "MS950_HKSCS"     // JDK historical;
  67                 });
  68 
  69         charset("x-windows-950", "MS950",
  70                 new String[] {
  71                     "ms950",    // JDK historical
  72                     "windows-950"
  73                 });
  74 
  75         charset("x-windows-874", "MS874",
  76                 new String[] {
  77                     "ms874",  // JDK historical
  78                     "ms-874",
  79                     "windows-874" });
  80 
  81         charset("x-EUC-TW", "EUC_TW",
  82                 new String[] {
  83                     "euc_tw", // JDK historical
  84                     "euctw",
  85                     "cns11643",
  86                     "EUC-TW"
  87                 });
  88 
  89         charset("Big5-HKSCS", "Big5_HKSCS",
  90                 new String[] {
  91                     "Big5_HKSCS", // JDK historical
  92                     "big5hk",
  93                     "big5-hkscs",
  94                     "big5hkscs"   // Linux alias
  95                 });
  96 
  97         charset("x-Big5-HKSCS-2001", "Big5_HKSCS_2001",
  98                 new String[] {
  99                     "Big5_HKSCS_2001",
 100                     "big5hk-2001",
 101                     "big5-hkscs-2001",
 102                     "big5-hkscs:unicode3.0",
 103                     "big5hkscs-2001",
 104                 });
 105 
 106         charset("x-Big5-Solaris", "Big5_Solaris",
 107                 new String[] {
 108                     "Big5_Solaris", // JDK historical
 109                 });
 110 
 111         // Simplified Chinese
 112         charset("GBK", "GBK",
 113                 new String[] {
 114                     "windows-936",
 115                     "CP936"
 116                 });
 117 
 118         charset("GB18030", "GB18030",
 119                 new String[] {
 120                     "gb18030-2000"
 121                 });
 122 
 123         charset("GB2312", "EUC_CN",
 124                 new String[] {
 125                     // IANA aliases
 126                     "gb2312",
 127                     "gb2312-80",
 128                     "gb2312-1980",
 129                     "euc-cn",
 130                     "euccn",
 131                     "x-EUC-CN", // 1.4 compatability
 132                     "EUC_CN" //JDK historical
 133                 });
 134 
 135         charset("x-mswin-936", "MS936",
 136                 new String[] {
 137                     "ms936", // historical
 138                     // IANA aliases
 139                     "ms_936"
 140                 });
 141 
 142         // The definition of this charset may be overridden by the init method,
 143         // below, if the sun.nio.cs.map property is defined.
 144         //
 145         charset("Shift_JIS", "SJIS",
 146                 new String[] {
 147                     // IANA aliases
 148                     "sjis", // historical
 149                     "shift_jis",
 150                     "shift-jis",
 151                     "ms_kanji",
 152                     "x-sjis",
 153                     "csShiftJIS"
 154                 });
 155 
 156         // The definition of this charset may be overridden by the init method,
 157         // below, if the sun.nio.cs.map property is defined.
 158         //
 159         charset("windows-31j", "MS932",
 160                 new String[] {
 161                     "MS932", // JDK historical
 162                     "windows-932",
 163                     "csWindows31J"
 164                 });
 165 
 166         charset("JIS_X0201", "JIS_X_0201",
 167                 new String[] {
 168                     "JIS0201", // JDK historical
 169                     // IANA aliases
 170                     "JIS_X0201",
 171                     "X0201",
 172                     "csHalfWidthKatakana"
 173                 });
 174 
 175         charset("x-JIS0208", "JIS_X_0208",
 176                 new String[] {
 177                     "JIS0208", // JDK historical
 178                     // IANA aliases
 179                     "JIS_C6226-1983",
 180                     "iso-ir-87",
 181                     "x0208",
 182                     "JIS_X0208-1983",
 183                     "csISO87JISX0208"
 184                 });
 185 
 186         charset("JIS_X0212-1990", "JIS_X_0212",
 187                 new String[] {
 188                     "JIS0212", // JDK historical
 189                     // IANA aliases
 190                     "jis_x0212-1990",
 191                     "x0212",
 192                     "iso-ir-159",
 193                     "csISO159JISX02121990"
 194                 });
 195 
 196         charset("x-SJIS_0213", "SJIS_0213",
 197                 new String[] {
 198                     "sjis-0213",
 199                     "sjis_0213",
 200                     "sjis:2004",
 201                     "sjis_0213:2004",
 202                     "shift_jis_0213:2004",
 203                     "shift_jis:2004"
 204                 });
 205 
 206         charset("x-MS932_0213", "MS932_0213",
 207                 new String[] {
 208                     "MS932-0213",
 209                     "MS932_0213",
 210                     "MS932:2004",
 211                     "windows-932-0213",
 212                     "windows-932:2004"
 213                 });
 214 
 215         charset("EUC-JP", "EUC_JP",
 216                 new String[] {
 217                     "euc_jp", // JDK historical
 218                     // IANA aliases
 219                     "eucjis",
 220                     "eucjp",
 221                     "Extended_UNIX_Code_Packed_Format_for_Japanese",
 222                     "csEUCPkdFmtjapanese",
 223                     "x-euc-jp",
 224                     "x-eucjp"
 225                 });
 226 
 227         charset("x-euc-jp-linux", "EUC_JP_LINUX",
 228                 new String[] {
 229                     "euc_jp_linux", // JDK historical
 230                     "euc-jp-linux"
 231                 });
 232 
 233         charset("x-eucjp-open", "EUC_JP_Open",
 234                 new String[] {
 235                     "EUC_JP_Solaris",   // JDK historical
 236                     "eucJP-open"
 237                 });
 238 
 239         charset("x-PCK", "PCK",
 240                 new String[] {
 241                     // IANA aliases
 242                     "pck" // historical
 243                 });
 244 
 245         charset("ISO-2022-JP", "ISO2022_JP",
 246             new String[] {
 247             // IANA aliases
 248             "iso2022jp", // historical
 249             "jis",
 250             "csISO2022JP",
 251             "jis_encoding",
 252             "csjisencoding"
 253         });
 254 
 255         charset("ISO-2022-JP-2", "ISO2022_JP_2",
 256             new String[] {
 257             // IANA aliases
 258             "csISO2022JP2",
 259             "iso2022jp2"
 260         });
 261 
 262         charset("x-windows-50221", "MS50221",
 263             new String[] {
 264             "ms50221", // historical
 265             "cp50221",
 266         });
 267 
 268         charset("x-windows-50220", "MS50220",
 269             new String[] {
 270             "ms50220", // historical
 271             "cp50220",
 272         });
 273 
 274         charset("x-windows-iso2022jp", "MSISO2022JP",
 275             new String[] {
 276             "windows-iso2022jp", // historical
 277         });
 278 
 279         charset("x-JISAutoDetect", "JISAutoDetect",
 280                 new String[] {
 281                     "JISAutoDetect" // historical
 282                 });
 283 
 284         // Korean
 285         charset("EUC-KR", "EUC_KR",
 286                 new String[] {
 287                     "euc_kr", // JDK historical
 288                     // IANA aliases
 289                     "ksc5601",
 290                     "euckr",
 291                     "ks_c_5601-1987",
 292                     "ksc5601-1987",
 293                     "ksc5601_1987",
 294                     "ksc_5601",
 295                     "csEUCKR",
 296                     "5601"
 297                 });
 298 
 299         charset("x-windows-949", "MS949",
 300                 new String[] {
 301                     "ms949",    // JDK historical
 302                     "windows949",
 303                     "windows-949",
 304                     // IANA aliases
 305                     "ms_949"
 306                 });
 307 
 308         charset("x-Johab", "Johab",
 309                 new String[] {
 310                         "ksc5601-1992",
 311                         "ksc5601_1992",
 312                         "ms1361",
 313                         "johab" // JDK historical
 314                 });
 315 
 316         charset("ISO-2022-KR", "ISO2022_KR",
 317                 new String[] {
 318                         "ISO2022KR", // JDK historical
 319                         "csISO2022KR"
 320                 });
 321 
 322         charset("ISO-2022-CN", "ISO2022_CN",
 323                 new String[] {
 324                         "ISO2022CN", // JDK historical
 325                         "csISO2022CN"
 326                 });
 327 
 328         charset("x-ISO-2022-CN-CNS", "ISO2022_CN_CNS",
 329                 new String[] {
 330                         "ISO2022CN_CNS", // JDK historical
 331                         "ISO-2022-CN-CNS"
 332                 });
 333 
 334         charset("x-ISO-2022-CN-GB", "ISO2022_CN_GB",
 335                 new String[] {
 336                         "ISO2022CN_GB", // JDK historical
 337                         "ISO-2022-CN-GB"
 338                 });
 339 
 340         charset("x-ISCII91", "ISCII91",
 341                 new String[] {
 342                         "iscii",
 343                         "ST_SEV_358-88",
 344                         "iso-ir-153",
 345                         "csISO153GOST1976874",
 346                         "ISCII91" // JDK historical
 347                 });
 348 
 349         charset("ISO-8859-3", "ISO_8859_3",
 350                 new String[] {
 351                     "iso8859_3", // JDK historical
 352                     "8859_3",
 353                     "ISO_8859-3:1988",
 354                     "iso-ir-109",
 355                     "ISO_8859-3",
 356                     "ISO8859-3",
 357                     "latin3",
 358                     "l3",
 359                     "ibm913",
 360                     "ibm-913",
 361                     "cp913",
 362                     "913",
 363                     "csISOLatin3"
 364                 });
 365 
 366         charset("ISO-8859-6", "ISO_8859_6",
 367                 new String[] {
 368                     "iso8859_6", // JDK historical
 369                     "8859_6",
 370                     "iso-ir-127",
 371                     "ISO_8859-6",
 372                     "ISO_8859-6:1987",
 373                     "ISO8859-6",
 374                     "ECMA-114",
 375                     "ASMO-708",
 376                     "arabic",
 377                     "ibm1089",
 378                     "ibm-1089",
 379                     "cp1089",
 380                     "1089",
 381                     "csISOLatinArabic"
 382                 });
 383 
 384         charset("ISO-8859-8", "ISO_8859_8",
 385                 new String[] {
 386                     "iso8859_8", // JDK historical
 387                     "8859_8",
 388                     "iso-ir-138",
 389                     "ISO_8859-8",
 390                     "ISO_8859-8:1988",
 391                     "ISO8859-8",
 392                     "cp916",
 393                     "916",
 394                     "ibm916",
 395                     "ibm-916",
 396                     "hebrew",
 397                     "csISOLatinHebrew"
 398                 });
 399 
 400         charset("x-ISO-8859-11", "ISO_8859_11",
 401                 new String[] {
 402                     "iso-8859-11",
 403                     "iso8859_11"
 404                 });
 405 
 406         charset("TIS-620", "TIS_620",
 407                 new String[] {
 408                     "tis620", // JDK historical
 409                     "tis620.2533"
 410                 });
 411 
 412         // Various Microsoft Windows international codepages
 413 
 414         charset("windows-1255", "MS1255",
 415                 new String[] {
 416                     "cp1255" // JDK historical
 417                 });
 418 
 419         charset("windows-1256", "MS1256",
 420                 new String[] {
 421                     "cp1256" // JDK historical
 422                 });
 423 
 424         charset("windows-1258", "MS1258",
 425                 new String[] {
 426                     "cp1258" // JDK historical
 427                 });
 428 
 429         // IBM & PC/MSDOS encodings
 430 
 431         charset("x-IBM942", "IBM942",
 432                 new String[] {
 433                     "cp942", // JDK historical
 434                     "ibm942",
 435                     "ibm-942",
 436                     "942"
 437                 });
 438 
 439         charset("x-IBM942C", "IBM942C",
 440                 new String[] {
 441                     "cp942C", // JDK historical
 442                     "ibm942C",
 443                     "ibm-942C",
 444                     "942C"
 445                 });
 446 
 447         charset("x-IBM943", "IBM943",
 448                 new String[] {
 449                     "cp943", // JDK historical
 450                     "ibm943",
 451                     "ibm-943",
 452                     "943"
 453                 });
 454 
 455         charset("x-IBM943C", "IBM943C",
 456                 new String[] {
 457                     "cp943C", // JDK historical
 458                     "ibm943C",
 459                     "ibm-943C",
 460                     "943C"
 461                 });
 462 
 463         charset("x-IBM948", "IBM948",
 464                 new String[] {
 465                     "cp948", // JDK historical
 466                     "ibm948",
 467                     "ibm-948",
 468                     "948"
 469                 });
 470 
 471         charset("x-IBM950", "IBM950",
 472                 new String[] {
 473                     "cp950", // JDK historical
 474                     "ibm950",
 475                     "ibm-950",
 476                     "950"
 477                 });
 478 
 479         charset("x-IBM930", "IBM930",
 480                 new String[] {
 481                     "cp930", // JDK historical
 482                     "ibm930",
 483                     "ibm-930",
 484                     "930"
 485                 });
 486 
 487         charset("x-IBM935", "IBM935",
 488                 new String[] {
 489                     "cp935", // JDK historical
 490                     "ibm935",
 491                     "ibm-935",
 492                     "935"
 493                 });
 494 
 495         charset("x-IBM937", "IBM937",
 496                 new String[] {
 497                     "cp937", // JDK historical
 498                     "ibm937",
 499                     "ibm-937",
 500                     "937"
 501                 });
 502 
 503         charset("x-IBM856", "IBM856",
 504                 new String[] {
 505                     "cp856", // JDK historical
 506                     "ibm-856",
 507                     "ibm856",
 508                     "856"
 509                 });
 510 
 511         charset("IBM860", "IBM860",
 512                 new String[] {
 513                     "cp860", // JDK historical
 514                     "ibm860",
 515                     "ibm-860",
 516                     "860",
 517                     "csIBM860"
 518                 });
 519         charset("IBM861", "IBM861",
 520                 new String[] {
 521                     "cp861", // JDK historical
 522                     "ibm861",
 523                     "ibm-861",
 524                     "861",
 525                     "csIBM861",
 526                     "cp-is"
 527                 });
 528 
 529         charset("IBM863", "IBM863",
 530                 new String[] {
 531                     "cp863", // JDK historical
 532                     "ibm863",
 533                     "ibm-863",
 534                     "863",
 535                     "csIBM863"
 536                 });
 537 
 538         charset("IBM864", "IBM864",
 539                 new String[] {
 540                     "cp864", // JDK historical
 541                     "ibm864",
 542                     "ibm-864",
 543                     "864",
 544                     "csIBM864"
 545                 });
 546 
 547         charset("IBM865", "IBM865",
 548                 new String[] {
 549                     "cp865", // JDK historical
 550                     "ibm865",
 551                     "ibm-865",
 552                     "865",
 553                     "csIBM865"
 554                 });
 555 
 556         charset("IBM868", "IBM868",
 557                 new String[] {
 558                     "cp868", // JDK historical
 559                     "ibm868",
 560                     "ibm-868",
 561                     "868",
 562                     "cp-ar",
 563                     "csIBM868"
 564                 });
 565 
 566         charset("IBM869", "IBM869",
 567                 new String[] {
 568                     "cp869", // JDK historical
 569                     "ibm869",
 570                     "ibm-869",
 571                     "869",
 572                     "cp-gr",
 573                     "csIBM869"
 574                 });
 575 
 576         charset("x-IBM921", "IBM921",
 577                 new String[] {
 578                     "cp921", // JDK historical
 579                     "ibm921",
 580                     "ibm-921",
 581                     "921"
 582                 });
 583 
 584         charset("x-IBM1006", "IBM1006",
 585                 new String[] {
 586                     "cp1006", // JDK historical
 587                     "ibm1006",
 588                     "ibm-1006",
 589                     "1006"
 590                 });
 591 
 592         charset("x-IBM1046", "IBM1046",
 593                 new String[] {
 594                     "cp1046", // JDK historical
 595                     "ibm1046",
 596                     "ibm-1046",
 597                     "1046"
 598                 });
 599 
 600         charset("IBM1047", "IBM1047",
 601                 new String[] {
 602                     "cp1047", // JDK historical
 603                     "ibm-1047",
 604                     "1047"
 605                 });
 606 
 607         charset("x-IBM1098", "IBM1098",
 608                 new String[] {
 609                     "cp1098", // JDK historical
 610                     "ibm1098",
 611                     "ibm-1098",
 612                     "1098",
 613                 });
 614 
 615         charset("IBM037", "IBM037",
 616                 new String[] {
 617                     "cp037", // JDK historical
 618                     "ibm037",
 619                     "ebcdic-cp-us",
 620                     "ebcdic-cp-ca",
 621                     "ebcdic-cp-wt",
 622                     "ebcdic-cp-nl",
 623                     "csIBM037",
 624                     "cs-ebcdic-cp-us",
 625                     "cs-ebcdic-cp-ca",
 626                     "cs-ebcdic-cp-wt",
 627                     "cs-ebcdic-cp-nl",
 628                     "ibm-037",
 629                     "ibm-37",
 630                     "cpibm37",
 631                     "037"
 632                 });
 633 
 634         charset("x-IBM1025", "IBM1025",
 635                 new String[] {
 636                     "cp1025", // JDK historical
 637                     "ibm1025",
 638                     "ibm-1025",
 639                     "1025"
 640                 });
 641 
 642         charset("IBM1026", "IBM1026",
 643                 new String[] {
 644                     "cp1026", // JDK historical
 645                     "ibm1026",
 646                     "ibm-1026",
 647                     "1026"
 648                 });
 649 
 650         charset("x-IBM1112", "IBM1112",
 651                 new String[] {
 652                     "cp1112", // JDK historical
 653                     "ibm1112",
 654                     "ibm-1112",
 655                     "1112"
 656                 });
 657 
 658         charset("x-IBM1122", "IBM1122",
 659                 new String[] {
 660                     "cp1122", // JDK historical
 661                     "ibm1122",
 662                     "ibm-1122",
 663                     "1122"
 664                 });
 665 
 666         charset("x-IBM1123", "IBM1123",
 667                 new String[] {
 668                     "cp1123", // JDK historical
 669                     "ibm1123",
 670                     "ibm-1123",
 671                     "1123"
 672                 });
 673 
 674         charset("x-IBM1124", "IBM1124",
 675                 new String[] {
 676                     "cp1124", // JDK historical
 677                     "ibm1124",
 678                     "ibm-1124",
 679                     "1124"
 680                 });
 681 
 682         charset("x-IBM1364", "IBM1364",
 683                 new String[] {
 684                     "cp1364",
 685                     "ibm1364",
 686                     "ibm-1364",
 687                     "1364"
 688                 });
 689 
 690         charset("IBM273", "IBM273",
 691                 new String[] {
 692                     "cp273", // JDK historical
 693                     "ibm273",
 694                     "ibm-273",
 695                     "273"
 696                 });
 697 
 698         charset("IBM277", "IBM277",
 699                 new String[] {
 700                     "cp277", // JDK historical
 701                     "ibm277",
 702                     "ibm-277",
 703                     "277"
 704                 });
 705 
 706         charset("IBM278", "IBM278",
 707                 new String[] {
 708                     "cp278", // JDK historical
 709                     "ibm278",
 710                     "ibm-278",
 711                     "278",
 712                     "ebcdic-sv",
 713                     "ebcdic-cp-se",
 714                     "csIBM278"
 715                 });
 716 
 717         charset("IBM280", "IBM280",
 718                 new String[] {
 719                     "cp280", // JDK historical
 720                     "ibm280",
 721                     "ibm-280",
 722                     "280"
 723                 });
 724 
 725         charset("IBM284", "IBM284",
 726                 new String[] {
 727                     "cp284", // JDK historical
 728                     "ibm284",
 729                     "ibm-284",
 730                     "284",
 731                     "csIBM284",
 732                     "cpibm284"
 733                 });
 734 
 735         charset("IBM285", "IBM285",
 736                 new String[] {
 737                     "cp285", // JDK historical
 738                     "ibm285",
 739                     "ibm-285",
 740                     "285",
 741                     "ebcdic-cp-gb",
 742                     "ebcdic-gb",
 743                     "csIBM285",
 744                     "cpibm285"
 745                 });
 746 
 747         charset("IBM297", "IBM297",
 748                 new String[] {
 749                     "cp297", // JDK historical
 750                     "ibm297",
 751                     "ibm-297",
 752                     "297",
 753                     "ebcdic-cp-fr",
 754                     "cpibm297",
 755                     "csIBM297",
 756                 });
 757 
 758         charset("IBM420", "IBM420",
 759                 new String[] {
 760                     "cp420", // JDK historical
 761                     "ibm420",
 762                     "ibm-420",
 763                     "ebcdic-cp-ar1",
 764                     "420",
 765                     "csIBM420"
 766                 });
 767 
 768         charset("IBM424", "IBM424",
 769                 new String[] {
 770                     "cp424", // JDK historical
 771                     "ibm424",
 772                     "ibm-424",
 773                     "424",
 774                     "ebcdic-cp-he",
 775                     "csIBM424"
 776                 });
 777 
 778         charset("IBM500", "IBM500",
 779                 new String[] {
 780                     "cp500", // JDK historical
 781                     "ibm500",
 782                     "ibm-500",
 783                     "500",
 784                     "ebcdic-cp-ch",
 785                     "ebcdic-cp-bh",
 786                     "csIBM500"
 787                 });
 788 
 789         charset("x-IBM833", "IBM833",
 790                 new String[] {
 791                      "cp833",
 792                      "ibm833",
 793                      "ibm-833"
 794                  });
 795 
 796         //EBCDIC DBCS-only Korean
 797         charset("x-IBM834", "IBM834",
 798                 new String[] {
 799                     "cp834",
 800                     "ibm834",
 801                     "834",
 802                     "ibm-834"
 803         });
 804 
 805 
 806         charset("IBM-Thai", "IBM838",
 807                 new String[] {
 808                     "cp838", // JDK historical
 809                     "ibm838",
 810                     "ibm-838",
 811                     "838"
 812                 });
 813 
 814         charset("IBM870", "IBM870",
 815                 new String[] {
 816                     "cp870", // JDK historical
 817                     "ibm870",
 818                     "ibm-870",
 819                     "870",
 820                     "ebcdic-cp-roece",
 821                     "ebcdic-cp-yu",
 822                     "csIBM870"
 823                 });
 824 
 825         charset("IBM871", "IBM871",
 826                 new String[] {
 827                     "cp871", // JDK historical
 828                     "ibm871",
 829                     "ibm-871",
 830                     "871",
 831                     "ebcdic-cp-is",
 832                     "csIBM871"
 833                 });
 834 
 835         charset("x-IBM875", "IBM875",
 836                 new String[] {
 837                     "cp875", // JDK historical
 838                     "ibm875",
 839                     "ibm-875",
 840                     "875"
 841                 });
 842 
 843         charset("IBM918", "IBM918",
 844                 new String[] {
 845                     "cp918", // JDK historical
 846                     "ibm-918",
 847                     "918",
 848                     "ebcdic-cp-ar2"
 849                 });
 850 
 851         charset("x-IBM922", "IBM922",
 852                 new String[] {
 853                     "cp922", // JDK historical
 854                     "ibm922",
 855                     "ibm-922",
 856                     "922"
 857                 });
 858 
 859         charset("x-IBM1097", "IBM1097",
 860                 new String[] {
 861                     "cp1097", // JDK historical
 862                     "ibm1097",
 863                     "ibm-1097",
 864                     "1097"
 865                 });
 866 
 867         charset("x-IBM949", "IBM949",
 868                 new String[] {
 869                     "cp949", // JDK historical
 870                     "ibm949",
 871                     "ibm-949",
 872                     "949"
 873                 });
 874 
 875         charset("x-IBM949C", "IBM949C",
 876                 new String[] {
 877                     "cp949C", // JDK historical
 878                     "ibm949C",
 879                     "ibm-949C",
 880                     "949C"
 881                 });
 882 
 883         charset("x-IBM939", "IBM939",
 884                 new String[] {
 885                     "cp939", // JDK historical
 886                     "ibm939",
 887                     "ibm-939",
 888                     "939"
 889                 });
 890 
 891         charset("x-IBM933", "IBM933",
 892                 new String[] {
 893                     "cp933", // JDK historical
 894                     "ibm933",
 895                     "ibm-933",
 896                     "933"
 897                 });
 898 
 899         charset("x-IBM1381", "IBM1381",
 900                 new String[] {
 901                     "cp1381", // JDK historical
 902                     "ibm1381",
 903                     "ibm-1381",
 904                     "1381"
 905                 });
 906 
 907         charset("x-IBM1383", "IBM1383",
 908                 new String[] {
 909                     "cp1383", // JDK historical
 910                     "ibm1383",
 911                     "ibm-1383",
 912                     "1383"
 913                 });
 914 
 915         charset("x-IBM970", "IBM970",
 916                 new String[] {
 917                     "cp970", // JDK historical
 918                     "ibm970",
 919                     "ibm-970",
 920                     "ibm-eucKR",
 921                     "970"
 922                 });
 923 
 924         charset("x-IBM964", "IBM964",
 925                 new String[] {
 926                     "cp964", // JDK historical
 927                     "ibm964",
 928                     "ibm-964",
 929                     "964"
 930                 });
 931 
 932         charset("x-IBM33722", "IBM33722",
 933                 new String[] {
 934                     "cp33722", // JDK historical
 935                     "ibm33722",
 936                     "ibm-33722",
 937                     "ibm-5050", // from IBM alias list
 938                     "ibm-33722_vascii_vpua", // from IBM alias list
 939                     "33722"
 940                 });
 941 
 942         charset("IBM01140", "IBM1140",
 943                 new String[] {
 944                     "cp1140", // JDK historical
 945                     "ccsid01140",
 946                     "cp01140",
 947                     "1140",
 948                     "ebcdic-us-037+euro"
 949                 });
 950 
 951         charset("IBM01141", "IBM1141",
 952                 new String[] {
 953                     "cp1141", // JDK historical
 954                     "ccsid01141",
 955                     "cp01141",
 956                     "1141",
 957                     "ebcdic-de-273+euro"
 958                 });
 959 
 960         charset("IBM01142", "IBM1142",
 961                 new String[] {
 962                     "cp1142", // JDK historical
 963                     "ccsid01142",
 964                     "cp01142",
 965                     "1142",
 966                     "ebcdic-no-277+euro",
 967                     "ebcdic-dk-277+euro"
 968                 });
 969 
 970         charset("IBM01143", "IBM1143",
 971                 new String[] {
 972                     "cp1143", // JDK historical
 973                     "ccsid01143",
 974                     "cp01143",
 975                     "1143",
 976                     "ebcdic-fi-278+euro",
 977                     "ebcdic-se-278+euro"
 978                 });
 979 
 980         charset("IBM01144", "IBM1144",
 981                 new String[] {
 982                     "cp1144", // JDK historical
 983                     "ccsid01144",
 984                     "cp01144",
 985                     "1144",
 986                     "ebcdic-it-280+euro"
 987                 });
 988 
 989         charset("IBM01145", "IBM1145",
 990                 new String[] {
 991                     "cp1145", // JDK historical
 992                     "ccsid01145",
 993                     "cp01145",
 994                     "1145",
 995                     "ebcdic-es-284+euro"
 996                 });
 997 
 998         charset("IBM01146", "IBM1146",
 999                 new String[] {
1000                     "cp1146", // JDK historical
1001                     "ccsid01146",
1002                     "cp01146",
1003                     "1146",
1004                     "ebcdic-gb-285+euro"
1005                 });
1006 
1007         charset("IBM01147", "IBM1147",
1008                 new String[] {
1009                     "cp1147", // JDK historical
1010                     "ccsid01147",
1011                     "cp01147",
1012                     "1147",
1013                     "ebcdic-fr-277+euro"
1014                 });
1015 
1016         charset("IBM01148", "IBM1148",
1017                 new String[] {
1018                     "cp1148", // JDK historical
1019                     "ccsid01148",
1020                     "cp01148",
1021                     "1148",
1022                     "ebcdic-international-500+euro"
1023                 });
1024 
1025         charset("IBM01149", "IBM1149",
1026                 new String[] {
1027                     "cp1149", // JDK historical
1028                     "ccsid01149",
1029                     "cp01149",
1030                     "1149",
1031                     "ebcdic-s-871+euro"
1032                 });
1033 
1034         // Macintosh MacOS/Apple char encodingd
1035 
1036 
1037         charset("x-MacRoman", "MacRoman",
1038                 new String[] {
1039                     "MacRoman" // JDK historical
1040                 });
1041 
1042         charset("x-MacCentralEurope", "MacCentralEurope",
1043                 new String[] {
1044                     "MacCentralEurope" // JDK historical
1045                 });
1046 
1047         charset("x-MacCroatian", "MacCroatian",
1048                 new String[] {
1049                     "MacCroatian" // JDK historical
1050                 });
1051 
1052 
1053         charset("x-MacGreek", "MacGreek",
1054                 new String[] {
1055                     "MacGreek" // JDK historical
1056                 });
1057 
1058         charset("x-MacCyrillic", "MacCyrillic",
1059                 new String[] {
1060                     "MacCyrillic" // JDK historical
1061                 });
1062 
1063         charset("x-MacUkraine", "MacUkraine",
1064                 new String[] {
1065                     "MacUkraine" // JDK historical
1066                 });
1067 
1068         charset("x-MacTurkish", "MacTurkish",
1069                 new String[] {
1070                     "MacTurkish" // JDK historical
1071                 });
1072 
1073         charset("x-MacArabic", "MacArabic",
1074                 new String[] {
1075                     "MacArabic" // JDK historical
1076                 });
1077 
1078         charset("x-MacHebrew", "MacHebrew",
1079                 new String[] {
1080                     "MacHebrew" // JDK historical
1081                 });
1082 
1083         charset("x-MacIceland", "MacIceland",
1084                 new String[] {
1085                     "MacIceland" // JDK historical
1086                 });
1087 
1088         charset("x-MacRomania", "MacRomania",
1089                 new String[] {
1090                     "MacRomania" // JDK historical
1091                 });
1092 
1093         charset("x-MacThai", "MacThai",
1094                 new String[] {
1095                     "MacThai" // JDK historical
1096                 });
1097 
1098         charset("x-MacSymbol", "MacSymbol",
1099                 new String[] {
1100                     "MacSymbol" // JDK historical
1101                 });
1102 
1103         charset("x-MacDingbat", "MacDingbat",
1104                 new String[] {
1105                     "MacDingbat" // JDK historical
1106                 });
1107 
1108         instance = this;
1109 
1110     }
1111 
1112     private boolean initialized = false;
1113 
1114     // If the sun.nio.cs.map property is defined on the command line we won't
1115     // see it in the system-properties table until after the charset subsystem
1116     // has been initialized.  We therefore delay the effect of this property
1117     // until after the JRE has completely booted.
1118     //
1119     // At the moment following values for this property are supported, property
1120     // value string is case insensitive.
1121     //
1122     // (1)"Windows-31J/Shift_JIS"
1123     // In 1.4.1 we added a correct implementation of the Shift_JIS charset
1124     // but in previous releases this charset name had been treated as an alias
1125     // for Windows-31J, aka MS932. Users who have existing code that depends
1126     // upon this alias can restore the previous behavior by defining this
1127     // property to have this value.
1128     //
1129     // (2)"x-windows-50221/ISO-2022-JP"
1130     //    "x-windows-50220/ISO-2022-JP"
1131     //    "x-windows-iso2022jp/ISO-2022-JP"
1132     // The charset ISO-2022-JP is a "standard based" implementation by default,
1133     // which supports ASCII, JIS_X_0201 and JIS_X_0208 mappings based encoding
1134     // and decoding only.
1135     // There are three Microsoft iso-2022-jp variants, namely x-windows-50220,
1136     // x-windows-50221 and x-windows-iso2022jp which behaves "slightly" differently
1137     // compared to the "standard based" implementation. See ISO2022_JP.java for
1138     // detailed description. Users who prefer the behavior of MS iso-2022-jp
1139     // variants should use these names explicitly instead of using "ISO-2022-JP"
1140     // and its aliases. However for those who need the ISO-2022-JP charset behaves
1141     // exactly the same as MS variants do, above properties can be defined to
1142     // switch.
1143     //
1144     // If we need to define other charset-alias mappings in the future then
1145     // this property could be further extended, the general idea being that its
1146     // value should be of the form
1147     //
1148     //     new-charset-1/old-charset-1,new-charset-2/old-charset-2,...
1149     //
1150     // where each charset named to the left of a slash is intended to replace
1151     // (most) uses of the charset named to the right of the slash.
1152     //
1153     protected void init() {
1154         if (initialized)
1155             return;
1156         if (!sun.misc.VM.isBooted())
1157             return;
1158 
1159         String map = AccessController.doPrivileged(
1160             new GetPropertyAction("sun.nio.cs.map"));
1161         boolean sjisIsMS932 = false;
1162         boolean iso2022jpIsMS50221 = false;
1163         boolean iso2022jpIsMS50220 = false;
1164         boolean iso2022jpIsMSISO2022JP = false;
1165         if (map != null) {
1166             String[] maps = map.split(",");
1167             for (int i = 0; i < maps.length; i++) {
1168                 if (maps[i].equalsIgnoreCase("Windows-31J/Shift_JIS")) {
1169                     sjisIsMS932 = true;
1170                 } else if (maps[i].equalsIgnoreCase("x-windows-50221/ISO-2022-JP")) {
1171                     iso2022jpIsMS50221 = true;
1172                 } else if (maps[i].equalsIgnoreCase("x-windows-50220/ISO-2022-JP")) {
1173                     iso2022jpIsMS50220 = true;
1174                 } else if (maps[i].equalsIgnoreCase("x-windows-iso2022jp/ISO-2022-JP")) {
1175                     iso2022jpIsMSISO2022JP = true;
1176                 }
1177             }
1178         }
1179         if (sjisIsMS932) {
1180             deleteCharset("Shift_JIS",
1181                           new String[] {
1182                               // IANA aliases
1183                               "sjis", // historical
1184                               "shift_jis",
1185                               "shift-jis",
1186                               "ms_kanji",
1187                               "x-sjis",
1188                               "csShiftJIS"
1189                           });
1190             deleteCharset("windows-31j",
1191                           new String[] {
1192                               "MS932", // JDK historical
1193                               "windows-932",
1194                               "csWindows31J"
1195                           });
1196             charset("Shift_JIS", "SJIS",
1197                     new String[] {
1198                         // IANA aliases
1199                         "sjis"          // JDK historical
1200                     });
1201             charset("windows-31j", "MS932",
1202                     new String[] {
1203                         "MS932",        // JDK historical
1204                         "windows-932",
1205                         "csWindows31J",
1206                         "shift-jis",
1207                         "ms_kanji",
1208                         "x-sjis",
1209                         "csShiftJIS",
1210                         // This alias takes precedence over the actual
1211                         // Shift_JIS charset itself since aliases are always
1212                         // resolved first, before looking up canonical names.
1213                         "shift_jis"
1214                     });
1215         }
1216         if (iso2022jpIsMS50221 ||
1217             iso2022jpIsMS50220 ||
1218             iso2022jpIsMSISO2022JP) {
1219             deleteCharset("ISO-2022-JP",
1220                           new String[] {
1221                               "iso2022jp",
1222                                 "jis",
1223                                 "csISO2022JP",
1224                                 "jis_encoding",
1225                                 "csjisencoding"
1226                           });
1227             if (iso2022jpIsMS50221) {
1228                 deleteCharset("x-windows-50221",
1229                               new String[] {
1230                                   "cp50221",
1231                                   "ms50221"
1232                               });
1233                 charset("x-windows-50221", "MS50221",
1234                         new String[] {
1235                             "cp50221",
1236                             "ms50221",
1237                             "iso-2022-jp",
1238                             "iso2022jp",
1239                             "jis",
1240                             "csISO2022JP",
1241                             "jis_encoding",
1242                             "csjisencoding"
1243                         });
1244             } else if (iso2022jpIsMS50220) {
1245                 deleteCharset("x-windows-50220",
1246                               new String[] {
1247                                   "cp50220",
1248                                   "ms50220"
1249                               });
1250                 charset("x-windows-50220", "MS50220",
1251                         new String[] {
1252                             "cp50220",
1253                             "ms50220",
1254                             "iso-2022-jp",
1255                             "iso2022jp",
1256                             "jis",
1257                             "csISO2022JP",
1258                             "jis_encoding",
1259                             "csjisencoding"
1260                         });
1261             } else {
1262                 deleteCharset("x-windows-iso2022jp",
1263                               new String[] {
1264                                   "windows-iso2022jp"
1265                               });
1266                 charset("x-windows-iso2022jp", "MSISO2022JP",
1267                         new String[] {
1268                             "windows-iso2022jp",
1269                             "iso-2022-jp",
1270                             "iso2022jp",
1271                             "jis",
1272                             "csISO2022JP",
1273                             "jis_encoding",
1274                             "csjisencoding"
1275                         });
1276 
1277 
1278             }
1279         }
1280         String osName = AccessController.doPrivileged(
1281             new GetPropertyAction("os.name"));
1282         if ("SunOS".equals(osName) || "Linux".equals(osName)
1283                || osName.contains("OS X")) {
1284             charset("x-COMPOUND_TEXT", "COMPOUND_TEXT",
1285                     new String[] {
1286                         "COMPOUND_TEXT",        // JDK historical
1287                         "x11-compound_text",
1288                         "x-compound-text"
1289                     });
1290         }
1291         initialized = true;
1292     }
1293 
1294     public static String[] aliasesFor(String charsetName) {
1295         if (instance == null)
1296             return null;
1297         return instance.aliases(charsetName);
1298     }
1299 }