1 /*
   2  * Copyright (c) 2002, 2010, 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("IBM273", "IBM273",
 683                 new String[] {
 684                     "cp273", // JDK historical
 685                     "ibm273",
 686                     "ibm-273",
 687                     "273"
 688                 });
 689 
 690         charset("IBM277", "IBM277",
 691                 new String[] {
 692                     "cp277", // JDK historical
 693                     "ibm277",
 694                     "ibm-277",
 695                     "277"
 696                 });
 697 
 698         charset("IBM278", "IBM278",
 699                 new String[] {
 700                     "cp278", // JDK historical
 701                     "ibm278",
 702                     "ibm-278",
 703                     "278",
 704                     "ebcdic-sv",
 705                     "ebcdic-cp-se",
 706                     "csIBM278"
 707                 });
 708 
 709         charset("IBM280", "IBM280",
 710                 new String[] {
 711                     "cp280", // JDK historical
 712                     "ibm280",
 713                     "ibm-280",
 714                     "280"
 715                 });
 716 
 717         charset("IBM284", "IBM284",
 718                 new String[] {
 719                     "cp284", // JDK historical
 720                     "ibm284",
 721                     "ibm-284",
 722                     "284",
 723                     "csIBM284",
 724                     "cpibm284"
 725                 });
 726 
 727         charset("IBM285", "IBM285",
 728                 new String[] {
 729                     "cp285", // JDK historical
 730                     "ibm285",
 731                     "ibm-285",
 732                     "285",
 733                     "ebcdic-cp-gb",
 734                     "ebcdic-gb",
 735                     "csIBM285",
 736                     "cpibm285"
 737                 });
 738 
 739         charset("IBM297", "IBM297",
 740                 new String[] {
 741                     "cp297", // JDK historical
 742                     "ibm297",
 743                     "ibm-297",
 744                     "297",
 745                     "ebcdic-cp-fr",
 746                     "cpibm297",
 747                     "csIBM297",
 748                 });
 749 
 750         charset("IBM420", "IBM420",
 751                 new String[] {
 752                     "cp420", // JDK historical
 753                     "ibm420",
 754                     "ibm-420",
 755                     "ebcdic-cp-ar1",
 756                     "420",
 757                     "csIBM420"
 758                 });
 759 
 760         charset("IBM424", "IBM424",
 761                 new String[] {
 762                     "cp424", // JDK historical
 763                     "ibm424",
 764                     "ibm-424",
 765                     "424",
 766                     "ebcdic-cp-he",
 767                     "csIBM424"
 768                 });
 769 
 770         charset("IBM500", "IBM500",
 771                 new String[] {
 772                     "cp500", // JDK historical
 773                     "ibm500",
 774                     "ibm-500",
 775                     "500",
 776                     "ebcdic-cp-ch",
 777                     "ebcdic-cp-bh",
 778                     "csIBM500"
 779                 });
 780 
 781         charset("x-IBM833", "IBM833",
 782                 new String[] {
 783                      "cp833",
 784                      "ibm833",
 785                      "ibm-833"
 786                  });
 787 
 788         //EBCDIC DBCS-only Korean
 789         charset("x-IBM834", "IBM834",
 790                 new String[] {
 791                     "cp834",
 792                     "ibm834",
 793                     "834",
 794                     "ibm-834"
 795         });
 796 
 797 
 798         charset("IBM-Thai", "IBM838",
 799                 new String[] {
 800                     "cp838", // JDK historical
 801                     "ibm838",
 802                     "ibm-838",
 803                     "838"
 804                 });
 805 
 806         charset("IBM870", "IBM870",
 807                 new String[] {
 808                     "cp870", // JDK historical
 809                     "ibm870",
 810                     "ibm-870",
 811                     "870",
 812                     "ebcdic-cp-roece",
 813                     "ebcdic-cp-yu",
 814                     "csIBM870"
 815                 });
 816 
 817         charset("IBM871", "IBM871",
 818                 new String[] {
 819                     "cp871", // JDK historical
 820                     "ibm871",
 821                     "ibm-871",
 822                     "871",
 823                     "ebcdic-cp-is",
 824                     "csIBM871"
 825                 });
 826 
 827         charset("x-IBM875", "IBM875",
 828                 new String[] {
 829                     "cp875", // JDK historical
 830                     "ibm875",
 831                     "ibm-875",
 832                     "875"
 833                 });
 834 
 835         charset("IBM918", "IBM918",
 836                 new String[] {
 837                     "cp918", // JDK historical
 838                     "ibm-918",
 839                     "918",
 840                     "ebcdic-cp-ar2"
 841                 });
 842 
 843         charset("x-IBM922", "IBM922",
 844                 new String[] {
 845                     "cp922", // JDK historical
 846                     "ibm922",
 847                     "ibm-922",
 848                     "922"
 849                 });
 850 
 851         charset("x-IBM1097", "IBM1097",
 852                 new String[] {
 853                     "cp1097", // JDK historical
 854                     "ibm1097",
 855                     "ibm-1097",
 856                     "1097"
 857                 });
 858 
 859         charset("x-IBM949", "IBM949",
 860                 new String[] {
 861                     "cp949", // JDK historical
 862                     "ibm949",
 863                     "ibm-949",
 864                     "949"
 865                 });
 866 
 867         charset("x-IBM949C", "IBM949C",
 868                 new String[] {
 869                     "cp949C", // JDK historical
 870                     "ibm949C",
 871                     "ibm-949C",
 872                     "949C"
 873                 });
 874 
 875         charset("x-IBM939", "IBM939",
 876                 new String[] {
 877                     "cp939", // JDK historical
 878                     "ibm939",
 879                     "ibm-939",
 880                     "939"
 881                 });
 882 
 883         charset("x-IBM933", "IBM933",
 884                 new String[] {
 885                     "cp933", // JDK historical
 886                     "ibm933",
 887                     "ibm-933",
 888                     "933"
 889                 });
 890 
 891         charset("x-IBM1381", "IBM1381",
 892                 new String[] {
 893                     "cp1381", // JDK historical
 894                     "ibm1381",
 895                     "ibm-1381",
 896                     "1381"
 897                 });
 898 
 899         charset("x-IBM1383", "IBM1383",
 900                 new String[] {
 901                     "cp1383", // JDK historical
 902                     "ibm1383",
 903                     "ibm-1383",
 904                     "1383"
 905                 });
 906 
 907         charset("x-IBM970", "IBM970",
 908                 new String[] {
 909                     "cp970", // JDK historical
 910                     "ibm970",
 911                     "ibm-970",
 912                     "ibm-eucKR",
 913                     "970"
 914                 });
 915 
 916         charset("x-IBM964", "IBM964",
 917                 new String[] {
 918                     "cp964", // JDK historical
 919                     "ibm964",
 920                     "ibm-964",
 921                     "964"
 922                 });
 923 
 924         charset("x-IBM33722", "IBM33722",
 925                 new String[] {
 926                     "cp33722", // JDK historical
 927                     "ibm33722",
 928                     "ibm-33722",
 929                     "ibm-5050", // from IBM alias list
 930                     "ibm-33722_vascii_vpua", // from IBM alias list
 931                     "33722"
 932                 });
 933 
 934         charset("IBM01140", "IBM1140",
 935                 new String[] {
 936                     "cp1140", // JDK historical
 937                     "ccsid01140",
 938                     "cp01140",
 939                     "1140",
 940                     "ebcdic-us-037+euro"
 941                 });
 942 
 943         charset("IBM01141", "IBM1141",
 944                 new String[] {
 945                     "cp1141", // JDK historical
 946                     "ccsid01141",
 947                     "cp01141",
 948                     "1141",
 949                     "ebcdic-de-273+euro"
 950                 });
 951 
 952         charset("IBM01142", "IBM1142",
 953                 new String[] {
 954                     "cp1142", // JDK historical
 955                     "ccsid01142",
 956                     "cp01142",
 957                     "1142",
 958                     "ebcdic-no-277+euro",
 959                     "ebcdic-dk-277+euro"
 960                 });
 961 
 962         charset("IBM01143", "IBM1143",
 963                 new String[] {
 964                     "cp1143", // JDK historical
 965                     "ccsid01143",
 966                     "cp01143",
 967                     "1143",
 968                     "ebcdic-fi-278+euro",
 969                     "ebcdic-se-278+euro"
 970                 });
 971 
 972         charset("IBM01144", "IBM1144",
 973                 new String[] {
 974                     "cp1144", // JDK historical
 975                     "ccsid01144",
 976                     "cp01144",
 977                     "1144",
 978                     "ebcdic-it-280+euro"
 979                 });
 980 
 981         charset("IBM01145", "IBM1145",
 982                 new String[] {
 983                     "cp1145", // JDK historical
 984                     "ccsid01145",
 985                     "cp01145",
 986                     "1145",
 987                     "ebcdic-es-284+euro"
 988                 });
 989 
 990         charset("IBM01146", "IBM1146",
 991                 new String[] {
 992                     "cp1146", // JDK historical
 993                     "ccsid01146",
 994                     "cp01146",
 995                     "1146",
 996                     "ebcdic-gb-285+euro"
 997                 });
 998 
 999         charset("IBM01147", "IBM1147",
1000                 new String[] {
1001                     "cp1147", // JDK historical
1002                     "ccsid01147",
1003                     "cp01147",
1004                     "1147",
1005                     "ebcdic-fr-277+euro"
1006                 });
1007 
1008         charset("IBM01148", "IBM1148",
1009                 new String[] {
1010                     "cp1148", // JDK historical
1011                     "ccsid01148",
1012                     "cp01148",
1013                     "1148",
1014                     "ebcdic-international-500+euro"
1015                 });
1016 
1017         charset("IBM01149", "IBM1149",
1018                 new String[] {
1019                     "cp1149", // JDK historical
1020                     "ccsid01149",
1021                     "cp01149",
1022                     "1149",
1023                     "ebcdic-s-871+euro"
1024                 });
1025 
1026         // Macintosh MacOS/Apple char encodingd
1027 
1028 
1029         charset("x-MacRoman", "MacRoman",
1030                 new String[] {
1031                     "MacRoman" // JDK historical
1032                 });
1033 
1034         charset("x-MacCentralEurope", "MacCentralEurope",
1035                 new String[] {
1036                     "MacCentralEurope" // JDK historical
1037                 });
1038 
1039         charset("x-MacCroatian", "MacCroatian",
1040                 new String[] {
1041                     "MacCroatian" // JDK historical
1042                 });
1043 
1044 
1045         charset("x-MacGreek", "MacGreek",
1046                 new String[] {
1047                     "MacGreek" // JDK historical
1048                 });
1049 
1050         charset("x-MacCyrillic", "MacCyrillic",
1051                 new String[] {
1052                     "MacCyrillic" // JDK historical
1053                 });
1054 
1055         charset("x-MacUkraine", "MacUkraine",
1056                 new String[] {
1057                     "MacUkraine" // JDK historical
1058                 });
1059 
1060         charset("x-MacTurkish", "MacTurkish",
1061                 new String[] {
1062                     "MacTurkish" // JDK historical
1063                 });
1064 
1065         charset("x-MacArabic", "MacArabic",
1066                 new String[] {
1067                     "MacArabic" // JDK historical
1068                 });
1069 
1070         charset("x-MacHebrew", "MacHebrew",
1071                 new String[] {
1072                     "MacHebrew" // JDK historical
1073                 });
1074 
1075         charset("x-MacIceland", "MacIceland",
1076                 new String[] {
1077                     "MacIceland" // JDK historical
1078                 });
1079 
1080         charset("x-MacRomania", "MacRomania",
1081                 new String[] {
1082                     "MacRomania" // JDK historical
1083                 });
1084 
1085         charset("x-MacThai", "MacThai",
1086                 new String[] {
1087                     "MacThai" // JDK historical
1088                 });
1089 
1090         charset("x-MacSymbol", "MacSymbol",
1091                 new String[] {
1092                     "MacSymbol" // JDK historical
1093                 });
1094 
1095         charset("x-MacDingbat", "MacDingbat",
1096                 new String[] {
1097                     "MacDingbat" // JDK historical
1098                 });
1099 
1100         instance = this;
1101 
1102     }
1103 
1104     private boolean initialized = false;
1105 
1106     // If the sun.nio.cs.map property is defined on the command line we won't
1107     // see it in the system-properties table until after the charset subsystem
1108     // has been initialized.  We therefore delay the effect of this property
1109     // until after the JRE has completely booted.
1110     //
1111     // At the moment following values for this property are supported, property
1112     // value string is case insensitive.
1113     //
1114     // (1)"Windows-31J/Shift_JIS"
1115     // In 1.4.1 we added a correct implementation of the Shift_JIS charset
1116     // but in previous releases this charset name had been treated as an alias
1117     // for Windows-31J, aka MS932. Users who have existing code that depends
1118     // upon this alias can restore the previous behavior by defining this
1119     // property to have this value.
1120     //
1121     // (2)"x-windows-50221/ISO-2022-JP"
1122     //    "x-windows-50220/ISO-2022-JP"
1123     //    "x-windows-iso2022jp/ISO-2022-JP"
1124     // The charset ISO-2022-JP is a "standard based" implementation by default,
1125     // which supports ASCII, JIS_X_0201 and JIS_X_0208 mappings based encoding
1126     // and decoding only.
1127     // There are three Microsoft iso-2022-jp variants, namely x-windows-50220,
1128     // x-windows-50221 and x-windows-iso2022jp which behaves "slightly" differently
1129     // compared to the "standard based" implementation. See ISO2022_JP.java for
1130     // detailed description. Users who prefer the behavior of MS iso-2022-jp
1131     // variants should use these names explicitly instead of using "ISO-2022-JP"
1132     // and its aliases. However for those who need the ISO-2022-JP charset behaves
1133     // exactly the same as MS variants do, above properties can be defined to
1134     // switch.
1135     //
1136     // If we need to define other charset-alias mappings in the future then
1137     // this property could be further extended, the general idea being that its
1138     // value should be of the form
1139     //
1140     //     new-charset-1/old-charset-1,new-charset-2/old-charset-2,...
1141     //
1142     // where each charset named to the left of a slash is intended to replace
1143     // (most) uses of the charset named to the right of the slash.
1144     //
1145     protected void init() {
1146         if (initialized)
1147             return;
1148         if (!sun.misc.VM.isBooted())
1149             return;
1150 
1151         String map = AccessController.doPrivileged(
1152             new GetPropertyAction("sun.nio.cs.map"));
1153         boolean sjisIsMS932 = false;
1154         boolean iso2022jpIsMS50221 = false;
1155         boolean iso2022jpIsMS50220 = false;
1156         boolean iso2022jpIsMSISO2022JP = false;
1157         if (map != null) {
1158             String[] maps = map.split(",");
1159             for (int i = 0; i < maps.length; i++) {
1160                 if (maps[i].equalsIgnoreCase("Windows-31J/Shift_JIS")) {
1161                     sjisIsMS932 = true;
1162                 } else if (maps[i].equalsIgnoreCase("x-windows-50221/ISO-2022-JP")) {
1163                     iso2022jpIsMS50221 = true;
1164                 } else if (maps[i].equalsIgnoreCase("x-windows-50220/ISO-2022-JP")) {
1165                     iso2022jpIsMS50220 = true;
1166                 } else if (maps[i].equalsIgnoreCase("x-windows-iso2022jp/ISO-2022-JP")) {
1167                     iso2022jpIsMSISO2022JP = true;
1168                 }
1169             }
1170         }
1171         if (sjisIsMS932) {
1172             deleteCharset("Shift_JIS",
1173                           new String[] {
1174                               // IANA aliases
1175                               "sjis", // historical
1176                               "shift_jis",
1177                               "shift-jis",
1178                               "ms_kanji",
1179                               "x-sjis",
1180                               "csShiftJIS"
1181                           });
1182             deleteCharset("windows-31j",
1183                           new String[] {
1184                               "MS932", // JDK historical
1185                               "windows-932",
1186                               "csWindows31J"
1187                           });
1188             charset("Shift_JIS", "SJIS",
1189                     new String[] {
1190                         // IANA aliases
1191                         "sjis"          // JDK historical
1192                     });
1193             charset("windows-31j", "MS932",
1194                     new String[] {
1195                         "MS932",        // JDK historical
1196                         "windows-932",
1197                         "csWindows31J",
1198                         "shift-jis",
1199                         "ms_kanji",
1200                         "x-sjis",
1201                         "csShiftJIS",
1202                         // This alias takes precedence over the actual
1203                         // Shift_JIS charset itself since aliases are always
1204                         // resolved first, before looking up canonical names.
1205                         "shift_jis"
1206                     });
1207         }
1208         if (iso2022jpIsMS50221 ||
1209             iso2022jpIsMS50220 ||
1210             iso2022jpIsMSISO2022JP) {
1211             deleteCharset("ISO-2022-JP",
1212                           new String[] {
1213                               "iso2022jp",
1214                                 "jis",
1215                                 "csISO2022JP",
1216                                 "jis_encoding",
1217                                 "csjisencoding"
1218                           });
1219             if (iso2022jpIsMS50221) {
1220                 deleteCharset("x-windows-50221",
1221                               new String[] {
1222                                   "cp50221",
1223                                   "ms50221"
1224                               });
1225                 charset("x-windows-50221", "MS50221",
1226                         new String[] {
1227                             "cp50221",
1228                             "ms50221",
1229                             "iso-2022-jp",
1230                             "iso2022jp",
1231                             "jis",
1232                             "csISO2022JP",
1233                             "jis_encoding",
1234                             "csjisencoding"
1235                         });
1236             } else if (iso2022jpIsMS50220) {
1237                 deleteCharset("x-windows-50220",
1238                               new String[] {
1239                                   "cp50220",
1240                                   "ms50220"
1241                               });
1242                 charset("x-windows-50220", "MS50220",
1243                         new String[] {
1244                             "cp50220",
1245                             "ms50220",
1246                             "iso-2022-jp",
1247                             "iso2022jp",
1248                             "jis",
1249                             "csISO2022JP",
1250                             "jis_encoding",
1251                             "csjisencoding"
1252                         });
1253             } else {
1254                 deleteCharset("x-windows-iso2022jp",
1255                               new String[] {
1256                                   "windows-iso2022jp"
1257                               });
1258                 charset("x-windows-iso2022jp", "MSISO2022JP",
1259                         new String[] {
1260                             "windows-iso2022jp",
1261                             "iso-2022-jp",
1262                             "iso2022jp",
1263                             "jis",
1264                             "csISO2022JP",
1265                             "jis_encoding",
1266                             "csjisencoding"
1267                         });
1268 
1269 
1270             }
1271         }
1272         String osName = AccessController.doPrivileged(
1273             new GetPropertyAction("os.name"));
1274         if ("SunOS".equals(osName) || "Linux".equals(osName)) {
1275             charset("x-COMPOUND_TEXT", "COMPOUND_TEXT",
1276                     new String[] {
1277                         "COMPOUND_TEXT",        // JDK historical
1278                         "x11-compound_text",
1279                         "x-compound-text"
1280                     });
1281         }
1282         initialized = true;
1283     }
1284 
1285     public static String[] aliasesFor(String charsetName) {
1286         if (instance == null)
1287             return null;
1288         return instance.aliases(charsetName);
1289     }
1290 }