1 /* |
1 /* |
2 * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
753 CHECK_NULL_RETURN(pjChar, NULL); |
748 CHECK_NULL_RETURN(pjChar, NULL); |
754 got = getLocaleInfoWrapper(pjChar, lcType, buf, BUFLEN); |
749 got = getLocaleInfoWrapper(pjChar, lcType, buf, BUFLEN); |
755 (*env)->ReleaseStringChars(env, jStr, pjChar); |
750 (*env)->ReleaseStringChars(env, jStr, pjChar); |
756 |
751 |
757 if (got) { |
752 if (got) { |
758 // Hack: Windows 10 returns "Unknown Region (XX)" for localized XX region name. |
753 return (*env)->NewString(env, buf, (jsize)wcslen(buf)); |
759 // Take that as not known. |
754 } else { |
760 if (type != sun_util_locale_provider_HostLocaleProviderAdapterImpl_DN_LOCALE_REGION || |
755 return NULL; |
761 wcsncmp(UNKNOWN_REGION, buf, UNKNOWN_REGION_SIZE) != 0) { |
756 } |
762 return (*env)->NewString(env, buf, (jsize)wcslen(buf)); |
|
763 } |
|
764 } |
|
765 |
|
766 return NULL; |
|
767 } |
757 } |
768 |
758 |
769 int getLocaleInfoWrapper(const jchar *langtag, LCTYPE type, LPWSTR data, int buflen) { |
759 int getLocaleInfoWrapper(const jchar *langtag, LCTYPE type, LPWSTR data, int buflen) { |
770 if (pGetLocaleInfoEx) { |
760 if (pGetLocaleInfoEx) { |
771 if (wcscmp(L"und", (LPWSTR)langtag) == 0) { |
761 if (wcscmp(L"und", (LPWSTR)langtag) == 0) { |