< prev index next >

src/java.base/windows/native/libjava/java_props_md.c

Print this page


   1 /*
   2  * Copyright (c) 1998, 2019, 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


 624     {
 625         WCHAR *homep = getHomeFromShell32();
 626         if (homep == NULL) {
 627             homep = L"C:\\";
 628         }
 629         sprops.user_home = homep;
 630     }
 631 
 632     /*
 633      *  user.language
 634      *  user.script, user.country, user.variant (if user's environment specifies them)
 635      *  file.encoding
 636      */
 637     {
 638         /*
 639          * query the system for the current system default locale
 640          * (which is a Windows LCID value),
 641          */
 642         LCID userDefaultLCID = GetUserDefaultLCID();
 643         LCID systemDefaultLCID = GetSystemDefaultLCID();
 644         LCID userDefaultUILang = GetUserDefaultUILanguage();

 645 
 646         {
 647             char * display_encoding;
 648             HANDLE hStdOutErr;
 649 
 650             // Windows UI Language selection list only cares "language"
 651             // information of the UI Language. For example, the list
 652             // just lists "English" but it actually means "en_US", and
 653             // the user cannot select "en_GB" (if exists) in the list.
 654             // So, this hack is to use the user LCID region information
 655             // for the UI Language, if the "language" portion of those
 656             // two locales are the same.
 657             if (PRIMARYLANGID(LANGIDFROMLCID(userDefaultLCID)) ==
 658                 PRIMARYLANGID(LANGIDFROMLCID(userDefaultUILang))) {
 659                 userDefaultUILang = userDefaultLCID;
 660             }
 661 
 662             SetupI18nProps(userDefaultLCID,
 663                            &sprops.format_language,
 664                            &sprops.format_script,
 665                            &sprops.format_country,
 666                            &sprops.format_variant,
 667                            &sprops.encoding);
 668             SetupI18nProps(userDefaultUILang,
 669                            &sprops.display_language,
 670                            &sprops.display_script,
 671                            &sprops.display_country,
 672                            &sprops.display_variant,
 673                            &display_encoding);
 674 
 675             sprops.sun_jnu_encoding = getEncodingInternal(systemDefaultLCID);
 676             if (LANGIDFROMLCID(userDefaultLCID) == 0x0c04 && majorVersion == 6) {
 677                 // MS claims "Vista has built-in support for HKSCS-2004.
 678                 // All of the HKSCS-2004 characters have Unicode 4.1.
 679                 // PUA code point assignments". But what it really means
 680                 // is that the HKSCS-2004 is ONLY supported in Unicode.
 681                 // Test indicates the MS950 in its zh_HK locale is a
 682                 // "regular" MS950 which does not handle HKSCS-2004 at
 683                 // all. Set encoding to MS950_HKSCS.
 684                 sprops.encoding = "MS950_HKSCS";
 685                 sprops.sun_jnu_encoding = "MS950_HKSCS";
 686             }
 687 
 688             hStdOutErr = GetStdHandle(STD_OUTPUT_HANDLE);


   1 /*
   2  * Copyright (c) 1998, 2020, 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


 624     {
 625         WCHAR *homep = getHomeFromShell32();
 626         if (homep == NULL) {
 627             homep = L"C:\\";
 628         }
 629         sprops.user_home = homep;
 630     }
 631 
 632     /*
 633      *  user.language
 634      *  user.script, user.country, user.variant (if user's environment specifies them)
 635      *  file.encoding
 636      */
 637     {
 638         /*
 639          * query the system for the current system default locale
 640          * (which is a Windows LCID value),
 641          */
 642         LCID userDefaultLCID = GetUserDefaultLCID();
 643         LCID systemDefaultLCID = GetSystemDefaultLCID();
 644         LANGID userDefaultUILang = GetUserDefaultUILanguage();
 645         LCID userDefaultUILCID = MAKELCID(userDefaultUILang, SORTIDFROMLCID(userDefaultLCID));
 646 
 647         {
 648             char * display_encoding;
 649             HANDLE hStdOutErr;
 650 
 651             // Windows UI Language selection list only cares "language"
 652             // information of the UI Language. For example, the list
 653             // just lists "English" but it actually means "en_US", and
 654             // the user cannot select "en_GB" (if exists) in the list.
 655             // So, this hack is to use the user LCID region information
 656             // for the UI Language, if the "language" portion of those
 657             // two locales are the same.
 658             if (PRIMARYLANGID(LANGIDFROMLCID(userDefaultLCID)) ==
 659                 PRIMARYLANGID(userDefaultUILang)) {
 660                 userDefaultUILCID = userDefaultLCID;
 661             }
 662 
 663             SetupI18nProps(userDefaultLCID,
 664                            &sprops.format_language,
 665                            &sprops.format_script,
 666                            &sprops.format_country,
 667                            &sprops.format_variant,
 668                            &sprops.encoding);
 669             SetupI18nProps(userDefaultUILCID,
 670                            &sprops.display_language,
 671                            &sprops.display_script,
 672                            &sprops.display_country,
 673                            &sprops.display_variant,
 674                            &display_encoding);
 675 
 676             sprops.sun_jnu_encoding = getEncodingInternal(systemDefaultLCID);
 677             if (LANGIDFROMLCID(userDefaultLCID) == 0x0c04 && majorVersion == 6) {
 678                 // MS claims "Vista has built-in support for HKSCS-2004.
 679                 // All of the HKSCS-2004 characters have Unicode 4.1.
 680                 // PUA code point assignments". But what it really means
 681                 // is that the HKSCS-2004 is ONLY supported in Unicode.
 682                 // Test indicates the MS950 in its zh_HK locale is a
 683                 // "regular" MS950 which does not handle HKSCS-2004 at
 684                 // all. Set encoding to MS950_HKSCS.
 685                 sprops.encoding = "MS950_HKSCS";
 686                 sprops.sun_jnu_encoding = "MS950_HKSCS";
 687             }
 688 
 689             hStdOutErr = GetStdHandle(STD_OUTPUT_HANDLE);


< prev index next >