From 2f780a4b4e4589c821890c69475c16f47feda0e0 Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Fri, 29 Apr 2022 12:44:47 -0400 Subject: [PATCH 1/8] Detect the default locale name during startup on Apple platforms This change adds a function to lookup the current NSLocale and extract the language + country code to load into ICU by default. Previously, we would defer to uloc_getDefault in ICU, which would return a value we would ignore (en_US_POSIX) and result in falling back to invariant mode. Fixes https://github.com/dotnet/runtime/issues/68321 --- .../CultureInfo/CultureInfoCurrentCulture.cs | 8 ++++++ src/mono/mono/mini/CMakeLists.txt | 7 +++++ .../CMakeLists.txt | 4 +++ .../System.Globalization.Native/pal_locale.c | 4 +++ .../System.Globalization.Native/pal_locale.m | 27 +++++++++++++++++++ .../pal_locale_internal.h | 10 +++++++ 6 files changed, 60 insertions(+) create mode 100644 src/native/libs/System.Globalization.Native/pal_locale.m diff --git a/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoCurrentCulture.cs b/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoCurrentCulture.cs index 9215095756e98..829a2e1dd1aa9 100644 --- a/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoCurrentCulture.cs +++ b/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoCurrentCulture.cs @@ -33,6 +33,14 @@ public void CurrentCulture() } } + [Fact] + [PlatformSpecific(TestPlatforms.OSX | TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS)] + public void CurrentCulture_Default_Not_Invariant() + { + Assert.NotEqual(CultureInfo.CurrentCulture, CultureInfo.InvariantCulture); + Assert.NotEqual(CultureInfo.CurrentUICulture, CultureInfo.InvariantCulture); + } + [Fact] public void CurrentCulture_Set_Null_ThrowsArgumentNullException() { diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index e09b23e4380eb..5921fb7371e7b 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -68,6 +68,13 @@ if(HAVE_SYS_ICU AND NOT HOST_WASI) pal_timeZoneInfo.c entrypoints.c ${pal_icushim_sources_base}) + + if (TARGET_DARWIN) + set(icu_shim_sources_base + ${icu_shim_sources_base} + pal_locale.m) + endif() + addprefix(icu_shim_sources "${ICU_SHIM_PATH}" "${icu_shim_sources_base}") set_source_files_properties(${icu_shim_sources} PROPERTIES COMPILE_DEFINITIONS OSX_ICU_LIBRARY_PATH="${OSX_ICU_LIBRARY_PATH}") set_source_files_properties(${icu_shim_sources} PROPERTIES COMPILE_FLAGS "-I\"${ICU_INCLUDEDIR}\" -I\"${CLR_SRC_NATIVE_DIR}/libs/System.Globalization.Native/\" -I\"${CLR_SRC_NATIVE_DIR}/libs/Common/\" ${ICU_FLAGS}") diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index d140506599692..2b935ba86618c 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -60,6 +60,10 @@ set(NATIVEGLOBALIZATION_SOURCES pal_icushim.c ) +if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_locale.m) +endif() + # time zone names are filtered out of icu data for the browser and associated functionality is disabled if (NOT CLR_CMAKE_TARGET_BROWSER) set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_timeZoneInfo.c) diff --git a/src/native/libs/System.Globalization.Native/pal_locale.c b/src/native/libs/System.Globalization.Native/pal_locale.c index cd0e25ed8837f..cc8cbe2fff689 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.c +++ b/src/native/libs/System.Globalization.Native/pal_locale.c @@ -134,7 +134,11 @@ int32_t FixupLocaleName(UChar* value, int32_t valueLength) // is not desirable at all because it doesn't support case insensitive string comparisons. const char* DetectDefaultLocaleName() { +#ifndef __APPLE__ const char* icuLocale = uloc_getDefault(); +#else + const char* icuLocale = DetectDefaultAppleLocaleName(); +#endif if (strcmp(icuLocale, "en_US_POSIX") == 0) { return ""; diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m new file mode 100644 index 0000000000000..2a2958e827071 --- /dev/null +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#include "pal_locale_internal.h" +#import + +const char* DetectDefaultAppleLocaleName() +{ + NSLocale *currentLocale = [NSLocale currentLocale]; + NSString *localeName = @""; + + if (!currentLocale) + { + return strdup([localeName UTF8String]); + } + + if ([currentLocale.languageCode length] > 0 && [currentLocale.countryCode length] > 0) + { + localeName = [NSString stringWithFormat:@"%@-%@", currentLocale.languageCode, currentLocale.countryCode]; + } + else + { + localeName = [currentLocale.localeIdentifier stringByReplacingOccurrencesOfString:@"_" withString:@"-"]; + } + + return strdup([localeName UTF8String]); +} diff --git a/src/native/libs/System.Globalization.Native/pal_locale_internal.h b/src/native/libs/System.Globalization.Native/pal_locale_internal.h index c58436ab77517..6861babf2eb4a 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_locale_internal.h @@ -51,3 +51,13 @@ Detect the default locale for the machine, defaulting to Invaraint if we can't compute one (different from uloc_getDefault()) would do. */ const char* DetectDefaultLocaleName(void); + +#ifdef __APPLE__ +/* +Function: +DetectDefaultSystemLocaleName + +Detects the default locale string for Apple platforms +*/ +const char* DetectDefaultAppleLocaleName(void); +#endif From 4741f33fe52710d71223d2b8b59d76fd18dd6aa7 Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Fri, 29 Apr 2022 15:45:58 -0400 Subject: [PATCH 2/8] Link in foundation and address feedback --- .../libs/System.Globalization.Native/CMakeLists.txt | 7 ++++++- .../libs/System.Globalization.Native/pal_locale.c | 10 ++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 2b935ba86618c..54dad314caf88 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -80,6 +80,11 @@ endif() include_directories("../Common") if (GEN_SHARED_LIB) + if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + include(CMakeFindFrameworks) + find_library(FOUNDATION Foundation REQUIRED) + endif() + add_library(System.Globalization.Native SHARED ${NATIVEGLOBALIZATION_SOURCES} @@ -88,12 +93,12 @@ if (GEN_SHARED_LIB) target_link_libraries(System.Globalization.Native dl + ${FOUNDATION} ) install_with_stripped_symbols (System.Globalization.Native PROGRAMS .) endif() - add_library(System.Globalization.Native-Static STATIC ${NATIVEGLOBALIZATION_SOURCES} diff --git a/src/native/libs/System.Globalization.Native/pal_locale.c b/src/native/libs/System.Globalization.Native/pal_locale.c index cc8cbe2fff689..dbc2a23c60579 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.c +++ b/src/native/libs/System.Globalization.Native/pal_locale.c @@ -134,11 +134,13 @@ int32_t FixupLocaleName(UChar* value, int32_t valueLength) // is not desirable at all because it doesn't support case insensitive string comparisons. const char* DetectDefaultLocaleName() { -#ifndef __APPLE__ - const char* icuLocale = uloc_getDefault(); -#else - const char* icuLocale = DetectDefaultAppleLocaleName(); + const char* icuLocale; +#ifdef __APPLE__ + icuLocale = DetectDefaultAppleLocaleName(); +if (icuLocale == NULL || icuLocale[0] == 0) #endif + icuLocale = uloc_getDefault(); + if (strcmp(icuLocale, "en_US_POSIX") == 0) { return ""; From f5adcfd3ef64ac1fbc5da7e5a886b1bf0c064106 Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Fri, 29 Apr 2022 18:41:32 -0400 Subject: [PATCH 3/8] Link in foundation in coreclr --- src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index a3837f8049220..bd6a653261c67 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -166,10 +166,15 @@ if(FEATURE_MERGE_JIT_AND_ENGINE) set(CLRJIT_STATIC clrjit_static) endif(FEATURE_MERGE_JIT_AND_ENGINE) +if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST) + include(CMakeFindFrameworks) + find_library(FOUNDATION Foundation REQUIRED) +endif() + target_sources(coreclr PUBLIC $) -target_link_libraries(coreclr PUBLIC ${CORECLR_LIBRARIES} ${CLRJIT_STATIC} cee_wks) +target_link_libraries(coreclr PUBLIC ${CORECLR_LIBRARIES} ${CLRJIT_STATIC} cee_wks ${FOUNDATION}) target_sources(coreclr_static PUBLIC $) -target_link_libraries(coreclr_static PUBLIC ${CORECLR_LIBRARIES} clrjit_static cee_wks_mergeable) +target_link_libraries(coreclr_static PUBLIC ${CORECLR_LIBRARIES} clrjit_static cee_wks_mergeable ${FOUNDATION}) target_compile_definitions(coreclr_static PUBLIC CORECLR_EMBEDDED) if(CLR_CMAKE_TARGET_WIN32) From 8db8113b2cdff24d61d657229fa4c373cc9bef5b Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Sat, 30 Apr 2022 00:35:52 -0400 Subject: [PATCH 4/8] Check LANG env variable first --- .../libs/System.Globalization.Native/pal_locale.m | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index 2a2958e827071..5534eb79028fa 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -1,19 +1,31 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#include #include "pal_locale_internal.h" + #import const char* DetectDefaultAppleLocaleName() { NSLocale *currentLocale = [NSLocale currentLocale]; NSString *localeName = @""; + const char* envLocaleName; + + // Match the ICU behavior where the default locale can be overriden by + // and env variable. + envLocaleName = getenv("LANG"); + + if (envLocaleName != NULL) + { + return envLocaleName; + } if (!currentLocale) { return strdup([localeName UTF8String]); } - + if ([currentLocale.languageCode length] > 0 && [currentLocale.countryCode length] > 0) { localeName = [NSString stringWithFormat:@"%@-%@", currentLocale.languageCode, currentLocale.countryCode]; @@ -25,3 +37,4 @@ return strdup([localeName UTF8String]); } + From 82f4e62a8ea0f7bb6fb2ae6a7ff82843ae750956 Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Mon, 2 May 2022 12:26:14 -0400 Subject: [PATCH 5/8] Defer to icu first, since it's looking for LANG and certain values. --- .../CultureInfo/CultureInfoCurrentCulture.cs | 24 ++++++++++++++++--- .../System.Globalization.Native/pal_locale.c | 9 +++---- .../System.Globalization.Native/pal_locale.m | 10 -------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoCurrentCulture.cs b/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoCurrentCulture.cs index 829a2e1dd1aa9..44afccec6b9f8 100644 --- a/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoCurrentCulture.cs +++ b/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoCurrentCulture.cs @@ -37,6 +37,9 @@ public void CurrentCulture() [PlatformSpecific(TestPlatforms.OSX | TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS)] public void CurrentCulture_Default_Not_Invariant() { + // On OSX-like platforms, it should default to what the default system culture is + // set to. Since we shouldn't assume en-US, we just test if it's not the invariant + // culture. Assert.NotEqual(CultureInfo.CurrentCulture, CultureInfo.InvariantCulture); Assert.NotEqual(CultureInfo.CurrentUICulture, CultureInfo.InvariantCulture); } @@ -133,7 +136,7 @@ public void CurrentCulture_BasedOnLangEnvVar(string langEnvVar, string expectedC }, expectedCultureName, new RemoteInvokeOptions { StartInfo = psi }).Dispose(); } - [PlatformSpecific(TestPlatforms.AnyUnix)] // When LANG is empty or unset, should default to the invariant culture on Unix. + [PlatformSpecific(TestPlatforms.AnyUnix)] [ConditionalTheory(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))] [InlineData("")] [InlineData(null)] @@ -149,13 +152,28 @@ public void CurrentCulture_DefaultWithNoLang(string langEnvVar) psi.Environment["LANG"] = langEnvVar; } + // When LANG is empty or unset, on Unix it should default to the invariant culture. + // On OSX-like platforms, it should default to what the default system culture is + // set to. Since we shouldn't assume en-US, we just test if it's not the invariant + // culture. RemoteExecutor.Invoke(() => { Assert.NotNull(CultureInfo.CurrentCulture); Assert.NotNull(CultureInfo.CurrentUICulture); - Assert.Equal("", CultureInfo.CurrentCulture.Name); - Assert.Equal("", CultureInfo.CurrentUICulture.Name); + if (PlatformDetection.IsOSXLike) + { + Assert.NotEqual("", CultureInfo.CurrentCulture.Name); + Assert.NotEqual("", CultureInfo.CurrentUICulture.Name); + + Assert.NotEqual(CultureInfo.CurrentCulture, CultureInfo.InvariantCulture); + Assert.NotEqual(CultureInfo.CurrentUICulture, CultureInfo.InvariantCulture); + } + else + { + Assert.Equal("", CultureInfo.CurrentCulture.Name); + Assert.Equal("", CultureInfo.CurrentUICulture.Name); + } }, new RemoteInvokeOptions { StartInfo = psi }).Dispose(); } diff --git a/src/native/libs/System.Globalization.Native/pal_locale.c b/src/native/libs/System.Globalization.Native/pal_locale.c index dbc2a23c60579..9297596ee0deb 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.c +++ b/src/native/libs/System.Globalization.Native/pal_locale.c @@ -135,15 +135,16 @@ int32_t FixupLocaleName(UChar* value, int32_t valueLength) const char* DetectDefaultLocaleName() { const char* icuLocale; -#ifdef __APPLE__ - icuLocale = DetectDefaultAppleLocaleName(); -if (icuLocale == NULL || icuLocale[0] == 0) -#endif + icuLocale = uloc_getDefault(); if (strcmp(icuLocale, "en_US_POSIX") == 0) { +#if TARGET_OS_MAC + icuLocale = DetectDefaultAppleLocaleName(); +#else return ""; +#endif } return icuLocale; diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index 5534eb79028fa..472f84501f69b 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -10,16 +10,6 @@ { NSLocale *currentLocale = [NSLocale currentLocale]; NSString *localeName = @""; - const char* envLocaleName; - - // Match the ICU behavior where the default locale can be overriden by - // and env variable. - envLocaleName = getenv("LANG"); - - if (envLocaleName != NULL) - { - return envLocaleName; - } if (!currentLocale) { From 5f034bcb19c6dbf37c5d319ee1ad32a1b1aede50 Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Mon, 2 May 2022 14:02:45 -0400 Subject: [PATCH 6/8] #ifdef not #if --- src/native/libs/System.Globalization.Native/pal_locale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/libs/System.Globalization.Native/pal_locale.c b/src/native/libs/System.Globalization.Native/pal_locale.c index 9297596ee0deb..3f5ca457fe8a7 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.c +++ b/src/native/libs/System.Globalization.Native/pal_locale.c @@ -140,7 +140,7 @@ const char* DetectDefaultLocaleName() if (strcmp(icuLocale, "en_US_POSIX") == 0) { -#if TARGET_OS_MAC +#ifdef TARGET_OS_MAC icuLocale = DetectDefaultAppleLocaleName(); #else return ""; From 5f367d5fcad90916cdb94531bff4955fb63b5a40 Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Tue, 3 May 2022 15:41:45 -0400 Subject: [PATCH 7/8] PR feedback --- .../System.Globalization.Native/pal_locale.c | 27 ++++++++++++++----- .../System.Globalization.Native/pal_locale.m | 2 +- .../pal_locale_internal.h | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/pal_locale.c b/src/native/libs/System.Globalization.Native/pal_locale.c index 3f5ca457fe8a7..471d3eb7d9dba 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.c +++ b/src/native/libs/System.Globalization.Native/pal_locale.c @@ -129,9 +129,11 @@ int32_t FixupLocaleName(UChar* value, int32_t valueLength) return i; } -// We use whatever ICU give us as the default locale except if it is en_US_POSIX. We'll map -// this POSIX locale to Invariant instead. The reason is POSIX locale collation behavior -// is not desirable at all because it doesn't support case insensitive string comparisons. +// We use whatever ICU give us as the default locale except if it is en_US_POSIX. +// +// On Apple related platforms (OSX, iOS, tvOS, MacCatalyst), we'll take what the system locale is. +// On all other platforms we'll map this POSIX locale to Invariant instead. +// The reason is POSIX locale collation behavior is not desirable at all because it doesn't support case insensitive string comparisons. const char* DetectDefaultLocaleName() { const char* icuLocale; @@ -140,11 +142,7 @@ const char* DetectDefaultLocaleName() if (strcmp(icuLocale, "en_US_POSIX") == 0) { -#ifdef TARGET_OS_MAC - icuLocale = DetectDefaultAppleLocaleName(); -#else return ""; -#endif } return icuLocale; @@ -223,6 +221,16 @@ int32_t GlobalizationNative_GetDefaultLocaleName(UChar* value, int32_t valueLeng const char* defaultLocale = DetectDefaultLocaleName(); +#ifdef __APPLE__ + char* appleLocale = NULL; + + if (strcmp(defaultLocale, "") == 0) + { + appleLocale = DetectDefaultAppleLocaleName(); + defaultLocale = appleLocale; + } +#endif + uloc_getBaseName(defaultLocale, localeNameBuffer, ULOC_FULLNAME_CAPACITY, &status); u_charsToUChars_safe(localeNameBuffer, value, valueLength, &status); @@ -243,6 +251,11 @@ int32_t GlobalizationNative_GetDefaultLocaleName(UChar* value, int32_t valueLeng } } +#ifdef __APPLE__ + if (appleLocale) + free(appleLocale); +#endif + return UErrorCodeToBool(status); } diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index 472f84501f69b..5015183724116 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -6,7 +6,7 @@ #import -const char* DetectDefaultAppleLocaleName() +char* DetectDefaultAppleLocaleName() { NSLocale *currentLocale = [NSLocale currentLocale]; NSString *localeName = @""; diff --git a/src/native/libs/System.Globalization.Native/pal_locale_internal.h b/src/native/libs/System.Globalization.Native/pal_locale_internal.h index 6861babf2eb4a..c754554bbfdd5 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_locale_internal.h @@ -59,5 +59,5 @@ DetectDefaultSystemLocaleName Detects the default locale string for Apple platforms */ -const char* DetectDefaultAppleLocaleName(void); +char* DetectDefaultAppleLocaleName(void); #endif From 28cd33923dec42a7721a05da5b8345ea65d5f191 Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Thu, 5 May 2022 13:31:27 -0400 Subject: [PATCH 8/8] Remove redundant string replace --- src/native/libs/System.Globalization.Native/pal_locale.c | 4 +--- src/native/libs/System.Globalization.Native/pal_locale.m | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/pal_locale.c b/src/native/libs/System.Globalization.Native/pal_locale.c index 471d3eb7d9dba..498f713404ca0 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.c +++ b/src/native/libs/System.Globalization.Native/pal_locale.c @@ -136,9 +136,7 @@ int32_t FixupLocaleName(UChar* value, int32_t valueLength) // The reason is POSIX locale collation behavior is not desirable at all because it doesn't support case insensitive string comparisons. const char* DetectDefaultLocaleName() { - const char* icuLocale; - - icuLocale = uloc_getDefault(); + const char* icuLocale = uloc_getDefault(); if (strcmp(icuLocale, "en_US_POSIX") == 0) { diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index 5015183724116..f574b9d14797e 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -22,7 +22,7 @@ } else { - localeName = [currentLocale.localeIdentifier stringByReplacingOccurrencesOfString:@"_" withString:@"-"]; + localeName = currentLocale.localeIdentifier; } return strdup([localeName UTF8String]);