1 /*
2 * Copyright (c) 2003, 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
692 "cp1255",
693 "cp1256",
694 "cp1257",
695 "ms874",
696 "ms932",
697 "gbk",
698 "ms949",
699 "ms950",
700 "ms1361",
701 };
702
703 private static String defaultCodePage = null;
704 static String getCodePage() {
705
706 if (defaultCodePage != null) {
707 return defaultCodePage;
708 }
709
710 if (FontUtilities.isWindows) {
711 defaultCodePage =
712 (String)java.security.AccessController.doPrivileged(
713 new sun.security.action.GetPropertyAction("file.encoding"));
714 } else {
715 if (languages.length != codePages.length) {
716 throw new InternalError("wrong code pages array length");
717 }
718 Locale locale = sun.awt.SunToolkit.getStartupLocale();
719
720 String language = locale.getLanguage();
721 if (language != null) {
722 if (language.equals("zh")) {
723 String country = locale.getCountry();
724 if (country != null) {
725 language = language + "_" + country;
726 }
727 }
728 for (int i=0; i<languages.length;i++) {
729 for (int l=0;l<languages[i].length; l++) {
730 if (language.equals(languages[i][l])) {
731 defaultCodePage = codePages[i];
732 return defaultCodePage;
1487 addLCIDMapEntry(map, "es_SV", (short) 0x440a);
1488 addLCIDMapEntry(map, "es_HN", (short) 0x480a);
1489 addLCIDMapEntry(map, "es_NI", (short) 0x4c0a);
1490 addLCIDMapEntry(map, "es_PR", (short) 0x500a);
1491
1492 lcidMap = map;
1493 }
1494
1495 private static short getLCIDFromLocale(Locale locale) {
1496 // optimize for common case
1497 if (locale.equals(Locale.US)) {
1498 return US_LCID;
1499 }
1500
1501 if (lcidMap == null) {
1502 createLCIDMap();
1503 }
1504
1505 String key = locale.toString();
1506 while (!"".equals(key)) {
1507 Short lcidObject = (Short) lcidMap.get(key);
1508 if (lcidObject != null) {
1509 return lcidObject.shortValue();
1510 }
1511 int pos = key.lastIndexOf('_');
1512 if (pos < 1) {
1513 return US_LCID;
1514 }
1515 key = key.substring(0, pos);
1516 }
1517
1518 return US_LCID;
1519 }
1520
1521 @Override
1522 public String getFamilyName(Locale locale) {
1523 if (locale == null) {
1524 return familyName;
1525 } else if (locale.equals(nameLocale) && localeFamilyName != null) {
1526 return localeFamilyName;
1527 } else {
|
1 /*
2 * Copyright (c) 2003, 2014, 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
692 "cp1255",
693 "cp1256",
694 "cp1257",
695 "ms874",
696 "ms932",
697 "gbk",
698 "ms949",
699 "ms950",
700 "ms1361",
701 };
702
703 private static String defaultCodePage = null;
704 static String getCodePage() {
705
706 if (defaultCodePage != null) {
707 return defaultCodePage;
708 }
709
710 if (FontUtilities.isWindows) {
711 defaultCodePage =
712 java.security.AccessController.doPrivileged(
713 new sun.security.action.GetPropertyAction("file.encoding"));
714 } else {
715 if (languages.length != codePages.length) {
716 throw new InternalError("wrong code pages array length");
717 }
718 Locale locale = sun.awt.SunToolkit.getStartupLocale();
719
720 String language = locale.getLanguage();
721 if (language != null) {
722 if (language.equals("zh")) {
723 String country = locale.getCountry();
724 if (country != null) {
725 language = language + "_" + country;
726 }
727 }
728 for (int i=0; i<languages.length;i++) {
729 for (int l=0;l<languages[i].length; l++) {
730 if (language.equals(languages[i][l])) {
731 defaultCodePage = codePages[i];
732 return defaultCodePage;
1487 addLCIDMapEntry(map, "es_SV", (short) 0x440a);
1488 addLCIDMapEntry(map, "es_HN", (short) 0x480a);
1489 addLCIDMapEntry(map, "es_NI", (short) 0x4c0a);
1490 addLCIDMapEntry(map, "es_PR", (short) 0x500a);
1491
1492 lcidMap = map;
1493 }
1494
1495 private static short getLCIDFromLocale(Locale locale) {
1496 // optimize for common case
1497 if (locale.equals(Locale.US)) {
1498 return US_LCID;
1499 }
1500
1501 if (lcidMap == null) {
1502 createLCIDMap();
1503 }
1504
1505 String key = locale.toString();
1506 while (!"".equals(key)) {
1507 Short lcidObject = lcidMap.get(key);
1508 if (lcidObject != null) {
1509 return lcidObject.shortValue();
1510 }
1511 int pos = key.lastIndexOf('_');
1512 if (pos < 1) {
1513 return US_LCID;
1514 }
1515 key = key.substring(0, pos);
1516 }
1517
1518 return US_LCID;
1519 }
1520
1521 @Override
1522 public String getFamilyName(Locale locale) {
1523 if (locale == null) {
1524 return familyName;
1525 } else if (locale.equals(nameLocale) && localeFamilyName != null) {
1526 return localeFamilyName;
1527 } else {
|