From: Jactry Zeng jzeng@codeweavers.com
This allows initializing locale from Mac locale identifiers like 'zh-Hans-US'. The current implementation recognizes it as 'zh-US' which isn't a valid locale identifier for Windows. --- dlls/ntdll/unix/env.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index 6b249917cfe..ebdb27262f5 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -833,18 +833,25 @@ static void init_locale(void) { CFStringRef lang = CFDictionaryGetValue( components, kCFLocaleLanguageCode ); CFStringRef country = CFDictionaryGetValue( components, kCFLocaleCountryCode ); + CFStringRef script = CFDictionaryGetValue( components, kCFLocaleScriptCode ); CFLocaleRef mac_user_locale = NULL; CFStringRef locale_string;
- if (!country) + if (script) + locale_string = CFStringCreateWithFormat( NULL, NULL, CFSTR("%@-%@"), lang, script ); + else { - mac_user_locale = CFLocaleCopyCurrent(); - country = CFLocaleGetValue( mac_user_locale, kCFLocaleCountryCode ); + if (!country) + { + mac_user_locale = CFLocaleCopyCurrent(); + country = CFLocaleGetValue( mac_user_locale, kCFLocaleCountryCode ); + } + if (country) + locale_string = CFStringCreateWithFormat( NULL, NULL, CFSTR("%@-%@"), lang, country ); + else + locale_string = CFStringCreateCopy( NULL, lang ); } - if (country) - locale_string = CFStringCreateWithFormat( NULL, NULL, CFSTR("%@-%@"), lang, country ); - else - locale_string = CFStringCreateCopy( NULL, lang ); + CFStringGetCString( locale_string, user_locale, sizeof(user_locale), kCFStringEncodingUTF8 ); CFRelease( locale_string ); if (mac_user_locale) CFRelease( mac_user_locale );