kernel32: Use RtlLocaleNameToLcid().
This commit is contained in:
parent
7ac7a902c8
commit
9f0983ddfc
|
@ -1182,32 +1182,12 @@ BOOL WINAPI GetUserPreferredUILanguages( DWORD flags, ULONG *count, WCHAR *buffe
|
|||
*/
|
||||
LCID WINAPI LocaleNameToLCID( LPCWSTR name, DWORD flags )
|
||||
{
|
||||
struct locale_name locale_name;
|
||||
static int once;
|
||||
LCID lcid;
|
||||
|
||||
if (flags && !once++)
|
||||
FIXME( "unsupported flags %x\n", flags );
|
||||
|
||||
if (name == LOCALE_NAME_USER_DEFAULT)
|
||||
return GetUserDefaultLCID();
|
||||
|
||||
/* string parsing */
|
||||
parse_locale_name( name, &locale_name );
|
||||
|
||||
TRACE( "found lcid %x for %s, matches %d\n",
|
||||
locale_name.lcid, debugstr_w(name), locale_name.matches );
|
||||
|
||||
if (!locale_name.matches)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (locale_name.matches == 1)
|
||||
WARN( "locale %s not recognized, defaulting to %s\n",
|
||||
debugstr_w(name), debugstr_w(locale_name.lang) );
|
||||
|
||||
return locale_name.lcid;
|
||||
if (!name) return GetUserDefaultLCID();
|
||||
if (!set_ntstatus( RtlLocaleNameToLcid( name, &lcid, 2 ))) return 0;
|
||||
if (!(flags & LOCALE_ALLOW_NEUTRAL_NAMES)) lcid = ConvertDefaultLocale( lcid );
|
||||
return lcid;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2570,18 +2550,9 @@ BOOL WINAPI IsValidLocale( LCID lcid, DWORD flags )
|
|||
*/
|
||||
BOOL WINAPI IsValidLocaleName( LPCWSTR locale )
|
||||
{
|
||||
struct locale_name locale_name;
|
||||
LCID lcid;
|
||||
|
||||
if (!locale)
|
||||
return FALSE;
|
||||
|
||||
/* string parsing */
|
||||
parse_locale_name( locale, &locale_name );
|
||||
|
||||
TRACE( "found lcid %x for %s, matches %d\n",
|
||||
locale_name.lcid, debugstr_w(locale), locale_name.matches );
|
||||
|
||||
return locale_name.matches > 0;
|
||||
return !RtlLocaleNameToLcid( locale, &lcid, 2 );
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
|
|
@ -2856,6 +2856,9 @@ static void test_LocaleNameToLCID(void)
|
|||
ok(lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN), SORT_DEFAULT), "Got wrong lcid for es-es: 0x%x\n", lcid);
|
||||
|
||||
/* english neutral name */
|
||||
lcid = pLocaleNameToLCID(enW, LOCALE_ALLOW_NEUTRAL_NAMES);
|
||||
ok(lcid == MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL), SORT_DEFAULT) ||
|
||||
broken(lcid == 0) /* Vista */, "got 0x%04x\n", lcid);
|
||||
lcid = pLocaleNameToLCID(enW, 0);
|
||||
ok(lcid == MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) ||
|
||||
broken(lcid == 0) /* Vista */, "got 0x%04x\n", lcid);
|
||||
|
@ -2871,6 +2874,7 @@ static void test_LocaleNameToLCID(void)
|
|||
*buffer = 0;
|
||||
ret = pLCIDToLocaleName(lcid, buffer, ARRAY_SIZE(buffer), 0);
|
||||
ok(ret > 0, "%s: got %d\n", wine_dbgstr_w(ptr->name), ret);
|
||||
todo_wine_if (ptr->todo)
|
||||
ok(!lstrcmpW(ptr->sname, buffer), "%s: got wrong locale name %s\n",
|
||||
wine_dbgstr_w(ptr->name), wine_dbgstr_w(buffer));
|
||||
|
||||
|
@ -4740,6 +4744,7 @@ static void test_GetLocaleInfoEx(void)
|
|||
static void test_IsValidLocaleName(void)
|
||||
{
|
||||
static const WCHAR enusW[] = {'e','n','-','U','S',0};
|
||||
static const WCHAR enW[] = {'e','n',0};
|
||||
static const WCHAR zzW[] = {'z','z',0};
|
||||
static const WCHAR zz_zzW[] = {'z','z','-','Z','Z',0};
|
||||
static const WCHAR zzzzW[] = {'z','z','z','z',0};
|
||||
|
@ -4753,6 +4758,8 @@ static void test_IsValidLocaleName(void)
|
|||
|
||||
ret = pIsValidLocaleName(enusW);
|
||||
ok(ret, "IsValidLocaleName failed\n");
|
||||
ret = pIsValidLocaleName(enW);
|
||||
ok(ret || broken(!ret), "IsValidLocaleName failed\n");
|
||||
ret = pIsValidLocaleName(zzW);
|
||||
ok(!ret || broken(ret), "IsValidLocaleName should have failed\n");
|
||||
ret = pIsValidLocaleName(zz_zzW);
|
||||
|
|
Loading…
Reference in New Issue