ReactOS 0.4.16-dev-92-g0c2cdca
locale.c File Reference
#include <k32.h>
#include <debug.h>
#include "lcformat_private.h"
Include dependency graph for locale.c:

Go to the source code of this file.

Classes

struct  locale_name
 
struct  registry_value
 
struct  enum_locale_ex_data
 
struct  ENUMLANGUAGEGROUP_CALLBACKS
 
struct  ENUMLANGUAGEGROUPLOCALE_CALLBACKS
 
struct  ENUM_UILANG_CALLBACK
 
struct  geoinfo_t
 

Macros

#define NDEBUG
 
#define WINVER   DLL_EXPORT_VERSION
 
#define LOCALE_NAME_USER_DEFAULT   NULL
 
#define REG_SZ   1
 
#define NLSRC_OFFSET   5000 /* FIXME */
 
#define LOCALE_LOCALEINFOFLAGSMASK
 
#define MB_FLAGSMASK   (MB_PRECOMPOSED|MB_COMPOSITE|MB_USEGLYPHCHARS|MB_ERR_INVALID_CHARS)
 
#define WC_FLAGSMASK
 
#define GET_UNIX_LOCALE(cat)
 

Enumerations

enum  locationkind { LOCATION_NATION = 0 , LOCATION_REGION , LOCATION_BOTH }
 
enum  {
  BASE = 36 , TMIN = 1 , TMAX = 26 , SKEW = 38 ,
  DAMP = 700 , INIT_BIAS = 72 , INIT_N = 128
}
 

Functions

 DEBUG_CHANNEL (nls)
 
INT WINAPI CompareStringEx (LPCWSTR locale, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2, LPNLSVERSIONINFO version, LPVOID reserved, LPARAM lParam)
 
int wine_fold_string (int flags, const WCHAR *src, int srclen, WCHAR *dst, int dstlen)
 
int wine_get_sortkey (int flags, const WCHAR *src, int srclen, char *dst, int dstlen)
 
int wine_compare_string (int flags, const WCHAR *str1, int len1, const WCHAR *str2, int len2)
 
UINT GetLocalisedText (IN UINT uID, IN LPWSTR lpszDest, IN UINT cchDest)
 
static void strcpynAtoW (WCHAR *dst, const char *src, size_t n)
 
static unsigned short get_table_entry (const unsigned short *table, WCHAR ch)
 
static UINT get_lcid_codepage (LCID lcid)
 
static const union cptableget_codepage_table (unsigned int codepage)
 
static LANGID get_default_sublang (LANGID lang)
 
static LCID convert_default_lcid (LCID lcid, LCTYPE lctype)
 
static BOOL is_genitive_name_supported (LCTYPE lctype)
 
static HANDLE create_registry_key (void)
 
static BOOL locale_update_registry (HKEY hkey, const WCHAR *name, LCID lcid, const LCTYPE *values, UINT nb_values)
 
void LOCALE_InitRegistry (void)
 
static const charget_locale (int category, const char *category_name)
 
static UINT setup_unix_locales (void)
 
LANGID WINAPI GetUserDefaultLangID (void)
 
LANGID WINAPI GetSystemDefaultLangID (void)
 
LCID WINAPI GetUserDefaultLCID (void)
 
LCID WINAPI GetSystemDefaultLCID (void)
 
INT WINAPI GetSystemDefaultLocaleName (LPWSTR localename, INT len)
 
static BOOL get_dummy_preferred_ui_language (DWORD flags, ULONG *count, WCHAR *buffer, ULONG *size)
 
BOOL WINAPI GetSystemPreferredUILanguages (DWORD flags, ULONG *count, WCHAR *buffer, ULONG *size)
 
BOOL WINAPI SetThreadPreferredUILanguages (DWORD flags, PCZZWSTR buffer, PULONG count)
 
BOOL WINAPI GetThreadPreferredUILanguages (DWORD flags, ULONG *count, WCHAR *buf, ULONG *size)
 
LANGID WINAPI GetUserDefaultUILanguage (void)
 
LANGID WINAPI GetSystemDefaultUILanguage (void)
 
static struct registry_valueget_locale_registry_value (DWORD lctype)
 
static INT get_registry_locale_info (struct registry_value *registry_value, LPWSTR buffer, INT len)
 
INT WINAPI GetLocaleInfoA (LCID lcid, LCTYPE lctype, LPSTR buffer, INT len)
 
static int get_value_base_by_lctype (LCTYPE lctype)
 
INT WINAPI GetLocaleInfoW (LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
 
BOOL WINAPI SetLocaleInfoA (LCID lcid, LCTYPE lctype, LPCSTR data)
 
BOOL WINAPI SetLocaleInfoW (LCID lcid, LCTYPE lctype, LPCWSTR data)
 
UINT WINAPI GetACP (void)
 
UINT WINAPI SetCPGlobal (UINT acp)
 
UINT WINAPI GetOEMCP (void)
 
BOOL WINAPI IsValidCodePage (UINT codepage)
 
BOOL WINAPI IsDBCSLeadByteEx (UINT codepage, BYTE testchar)
 
BOOL WINAPI IsDBCSLeadByte (BYTE testchar)
 
BOOL WINAPI GetCPInfo (UINT codepage, LPCPINFO cpinfo)
 
BOOL WINAPI GetCPInfoExA (UINT codepage, DWORD dwFlags, LPCPINFOEXA cpinfo)
 
BOOL WINAPI GetCPInfoExW (UINT codepage, DWORD dwFlags, LPCPINFOEXW cpinfo)
 
BOOL WINAPI EnumSystemCodePagesA (CODEPAGE_ENUMPROCA lpfnCodePageEnum, DWORD flags)
 
BOOL WINAPI EnumSystemCodePagesW (CODEPAGE_ENUMPROCW lpfnCodePageEnum, DWORD flags)
 
static BOOL utf7_write_w (WCHAR *dst, int dstlen, int *index, WCHAR character)
 
static int utf7_mbstowcs (const char *src, int srclen, WCHAR *dst, int dstlen)
 
INT WINAPI MultiByteToWideChar (UINT page, DWORD flags, LPCSTR src, INT srclen, LPWSTR dst, INT dstlen)
 
static BOOL utf7_can_directly_encode (WCHAR codepoint)
 
static BOOL utf7_write_c (char *dst, int dstlen, int *index, char character)
 
static int utf7_wcstombs (const WCHAR *src, int srclen, char *dst, int dstlen)
 
INT WINAPI WideCharToMultiByte (UINT page, DWORD flags, LPCWSTR src, INT srclen, LPSTR dst, INT dstlen, LPCSTR defchar, BOOL *used)
 
LCID WINAPI GetThreadLocale (void)
 
BOOL WINAPI SetThreadLocale (LCID lcid)
 
LANGID WINAPI SetThreadUILanguage (LANGID langid)
 
LCID WINAPI ConvertDefaultLocale (LCID lcid)
 
BOOL WINAPI IsValidLocale (LCID lcid, DWORD flags)
 
BOOL WINAPI IsValidLocaleName (LPCWSTR locale)
 
static BOOL CALLBACK enum_lang_proc_a (HMODULE hModule, LPCSTR type, LPCSTR name, WORD LangID, LONG_PTR lParam)
 
static BOOL CALLBACK enum_lang_proc_w (HMODULE hModule, LPCWSTR type, LPCWSTR name, WORD LangID, LONG_PTR lParam)
 
BOOL WINAPI EnumSystemLocalesA (LOCALE_ENUMPROCA lpfnLocaleEnum, DWORD dwFlags)
 
BOOL WINAPI EnumSystemLocalesW (LOCALE_ENUMPROCW lpfnLocaleEnum, DWORD dwFlags)
 
static BOOL CALLBACK enum_locale_ex_proc (HMODULE module, LPCWSTR type, LPCWSTR name, WORD lang, LONG_PTR lparam)
 
BOOL WINAPI EnumSystemLocalesEx (LOCALE_ENUMPROCEX proc, DWORD flags, LPARAM lparam, LPVOID reserved)
 
DWORD WINAPI VerLanguageNameA (DWORD wLang, LPSTR szLang, DWORD nSize)
 
DWORD WINAPI VerLanguageNameW (DWORD wLang, LPWSTR szLang, DWORD nSize)
 
BOOL WINAPI GetStringTypeW (DWORD type, LPCWSTR src, INT count, LPWORD chartype)
 
BOOL WINAPI GetStringTypeExW (LCID locale, DWORD type, LPCWSTR src, INT count, LPWORD chartype)
 
BOOL WINAPI GetStringTypeA (LCID locale, DWORD type, LPCSTR src, INT count, LPWORD chartype)
 
BOOL WINAPI GetStringTypeExA (LCID locale, DWORD type, LPCSTR src, INT count, LPWORD chartype)
 
INT WINAPI LCMapStringEx (LPCWSTR locale, DWORD flags, LPCWSTR src, INT srclen, LPWSTR dst, INT dstlen, LPNLSVERSIONINFO version, LPVOID reserved, LPARAM handle)
 
INT WINAPI LCMapStringW (LCID lcid, DWORD flags, LPCWSTR src, INT srclen, LPWSTR dst, INT dstlen)
 
INT WINAPI LCMapStringA (LCID lcid, DWORD flags, LPCSTR src, INT srclen, LPSTR dst, INT dstlen)
 
INT WINAPI FoldStringA (DWORD dwFlags, LPCSTR src, INT srclen, LPSTR dst, INT dstlen)
 
INT WINAPI FoldStringW (DWORD dwFlags, LPCWSTR src, INT srclen, LPWSTR dst, INT dstlen)
 
INT WINAPI CompareStringW (LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
 
INT WINAPI CompareStringA (LCID lcid, DWORD flags, LPCSTR str1, INT len1, LPCSTR str2, INT len2)
 
int WINAPI lstrcmpA (LPCSTR str1, LPCSTR str2)
 
int WINAPI lstrcmpiA (LPCSTR str1, LPCSTR str2)
 
int WINAPI lstrcmpW (LPCWSTR str1, LPCWSTR str2)
 
int WINAPI lstrcmpiW (LPCWSTR str1, LPCWSTR str2)
 
void LOCALE_Init (void)
 
static HANDLE NLS_RegOpenKey (HANDLE hRootKey, LPCWSTR szKeyName)
 
static BOOL NLS_RegEnumValue (HANDLE hKey, UINT ulIndex, LPWSTR szValueName, ULONG valueNameSize, LPWSTR szValueData, ULONG valueDataSize)
 
static BOOL NLS_RegGetDword (HANDLE hKey, LPCWSTR szValueName, DWORD *lpVal)
 
static BOOL NLS_GetLanguageGroupName (LGRPID lgrpid, LPWSTR szName, ULONG nameSize)
 
static BOOL NLS_EnumSystemLanguageGroups (ENUMLANGUAGEGROUP_CALLBACKS *lpProcs)
 
BOOL WINAPI EnumSystemLanguageGroupsA (LANGUAGEGROUP_ENUMPROCA pLangGrpEnumProc, DWORD dwFlags, LONG_PTR lParam)
 
BOOL WINAPI EnumSystemLanguageGroupsW (LANGUAGEGROUP_ENUMPROCW pLangGrpEnumProc, DWORD dwFlags, LONG_PTR lParam)
 
BOOL WINAPI IsValidLanguageGroup (LGRPID lgrpid, DWORD dwFlags)
 
static BOOL NLS_EnumLanguageGroupLocales (ENUMLANGUAGEGROUPLOCALE_CALLBACKS *lpProcs)
 
BOOL WINAPI EnumLanguageGroupLocalesA (LANGGROUPLOCALE_ENUMPROCA pLangGrpLcEnumProc, LGRPID lgrpid, DWORD dwFlags, LONG_PTR lParam)
 
BOOL WINAPI EnumLanguageGroupLocalesW (LANGGROUPLOCALE_ENUMPROCW pLangGrpLcEnumProc, LGRPID lgrpid, DWORD dwFlags, LONG_PTR lParam)
 
BOOL WINAPI InvalidateNLSCache (void)
 
GEOID WINAPI GetUserGeoID (GEOCLASS GeoClass)
 
BOOL WINAPI SetUserGeoID (GEOID GeoID)
 
static BOOL CALLBACK enum_uilang_proc_a (HMODULE hModule, LPCSTR type, LPCSTR name, WORD LangID, LONG_PTR lParam)
 
static BOOL CALLBACK enum_uilang_proc_w (HMODULE hModule, LPCWSTR type, LPCWSTR name, WORD LangID, LONG_PTR lParam)
 
BOOL WINAPI EnumUILanguagesA (UILANGUAGE_ENUMPROCA pUILangEnumProc, DWORD dwFlags, LONG_PTR lParam)
 
BOOL WINAPI EnumUILanguagesW (UILANGUAGE_ENUMPROCW pUILangEnumProc, DWORD dwFlags, LONG_PTR lParam)
 
static const struct geoinfo_tget_geoinfo_dataptr (GEOID geoid)
 
INT WINAPI GetGeoInfoW (GEOID geoid, GEOTYPE geotype, LPWSTR data, int data_len, LANGID lang)
 
INT WINAPI GetGeoInfoA (GEOID geoid, GEOTYPE geotype, LPSTR data, int data_len, LANGID lang)
 
BOOL WINAPI EnumSystemGeoID (GEOCLASS geoclass, GEOID parent, GEO_ENUMPROC enumproc)
 
INT WINAPI GetUserDefaultLocaleName (LPWSTR localename, int buffersize)
 
INT WINAPI NormalizeString (NORM_FORM NormForm, LPCWSTR lpSrcString, INT cwSrcLength, LPWSTR lpDstString, INT cwDstLength)
 
BOOL WINAPI IsNormalizedString (NORM_FORM NormForm, LPCWSTR lpString, INT cwLength)
 
static INT adapt (INT delta, INT numpoints, BOOL firsttime)
 
INT WINAPI IdnToAscii (DWORD dwFlags, LPCWSTR lpUnicodeCharStr, INT cchUnicodeChar, LPWSTR lpASCIICharStr, INT cchASCIIChar)
 
INT WINAPI IdnToNameprepUnicode (DWORD dwFlags, LPCWSTR lpUnicodeCharStr, INT cchUnicodeChar, LPWSTR lpNameprepCharStr, INT cchNameprepChar)
 
INT WINAPI IdnToUnicode (DWORD dwFlags, LPCWSTR lpASCIICharStr, INT cchASCIIChar, LPWSTR lpUnicodeCharStr, INT cchUnicodeChar)
 
BOOL WINAPI GetFileMUIPath (DWORD flags, PCWSTR filepath, PWSTR language, PULONG languagelen, PWSTR muipath, PULONG muipathlen, PULONGLONG enumerator)
 
BOOL WINAPI GetFileMUIInfo (DWORD flags, PCWSTR path, FILEMUIINFO *info, DWORD *size)
 
INT WINAPI ResolveLocaleName (LPCWSTR name, LPWSTR localename, INT len)
 

Variables

HMODULE kernel32_handle
 
static const union cptableansi_cptable
 
static const union cptableoem_cptable
 
static const union cptablemac_cptable
 
static const union cptableunix_cptable
 
static const WCHAR szLocaleKeyName []
 
static const WCHAR szLangGroupsKeyName []
 
static LCID lcid_LC_COLLATE
 
static LCID lcid_LC_CTYPE
 
static LCID lcid_LC_MESSAGES
 
static LCID lcid_LC_MONETARY
 
static LCID lcid_LC_NUMERIC
 
static LCID lcid_LC_TIME
 
static LCID lcid_LC_PAPER
 
static LCID lcid_LC_MEASUREMENT
 
static LCID lcid_LC_TELEPHONE
 
static const WCHAR iCalendarTypeW [] = {'i','C','a','l','e','n','d','a','r','T','y','p','e',0}
 
static const WCHAR iCountryW [] = {'i','C','o','u','n','t','r','y',0}
 
static const WCHAR iCurrDigitsW [] = {'i','C','u','r','r','D','i','g','i','t','s',0}
 
static const WCHAR iCurrencyW [] = {'i','C','u','r','r','e','n','c','y',0}
 
static const WCHAR iDateW [] = {'i','D','a','t','e',0}
 
static const WCHAR iDigitsW [] = {'i','D','i','g','i','t','s',0}
 
static const WCHAR iFirstDayOfWeekW [] = {'i','F','i','r','s','t','D','a','y','O','f','W','e','e','k',0}
 
static const WCHAR iFirstWeekOfYearW [] = {'i','F','i','r','s','t','W','e','e','k','O','f','Y','e','a','r',0}
 
static const WCHAR iLDateW [] = {'i','L','D','a','t','e',0}
 
static const WCHAR iLZeroW [] = {'i','L','Z','e','r','o',0}
 
static const WCHAR iMeasureW [] = {'i','M','e','a','s','u','r','e',0}
 
static const WCHAR iNegCurrW [] = {'i','N','e','g','C','u','r','r',0}
 
static const WCHAR iNegNumberW [] = {'i','N','e','g','N','u','m','b','e','r',0}
 
static const WCHAR iPaperSizeW [] = {'i','P','a','p','e','r','S','i','z','e',0}
 
static const WCHAR iTLZeroW [] = {'i','T','L','Z','e','r','o',0}
 
static const WCHAR iTimePrefixW [] = {'i','T','i','m','e','P','r','e','f','i','x',0}
 
static const WCHAR iTimeW [] = {'i','T','i','m','e',0}
 
static const WCHAR s1159W [] = {'s','1','1','5','9',0}
 
static const WCHAR s2359W [] = {'s','2','3','5','9',0}
 
static const WCHAR sCountryW [] = {'s','C','o','u','n','t','r','y',0}
 
static const WCHAR sCurrencyW [] = {'s','C','u','r','r','e','n','c','y',0}
 
static const WCHAR sDateW [] = {'s','D','a','t','e',0}
 
static const WCHAR sDecimalW [] = {'s','D','e','c','i','m','a','l',0}
 
static const WCHAR sGroupingW [] = {'s','G','r','o','u','p','i','n','g',0}
 
static const WCHAR sLanguageW [] = {'s','L','a','n','g','u','a','g','e',0}
 
static const WCHAR sListW [] = {'s','L','i','s','t',0}
 
static const WCHAR sLongDateW [] = {'s','L','o','n','g','D','a','t','e',0}
 
static const WCHAR sMonDecimalSepW [] = {'s','M','o','n','D','e','c','i','m','a','l','S','e','p',0}
 
static const WCHAR sMonGroupingW [] = {'s','M','o','n','G','r','o','u','p','i','n','g',0}
 
static const WCHAR sMonThousandSepW [] = {'s','M','o','n','T','h','o','u','s','a','n','d','S','e','p',0}
 
static const WCHAR sNativeDigitsW [] = {'s','N','a','t','i','v','e','D','i','g','i','t','s',0}
 
static const WCHAR sNegativeSignW [] = {'s','N','e','g','a','t','i','v','e','S','i','g','n',0}
 
static const WCHAR sPositiveSignW [] = {'s','P','o','s','i','t','i','v','e','S','i','g','n',0}
 
static const WCHAR sShortDateW [] = {'s','S','h','o','r','t','D','a','t','e',0}
 
static const WCHAR sThousandW [] = {'s','T','h','o','u','s','a','n','d',0}
 
static const WCHAR sTimeFormatW [] = {'s','T','i','m','e','F','o','r','m','a','t',0}
 
static const WCHAR sTimeW [] = {'s','T','i','m','e',0}
 
static const WCHAR sYearMonthW [] = {'s','Y','e','a','r','M','o','n','t','h',0}
 
static const WCHAR NumShapeW [] = {'N','u','m','s','h','a','p','e',0}
 
static struct registry_value registry_values []
 
static RTL_CRITICAL_SECTION cache_section = { NULL, -1, 0, 0, 0, 0 }
 
static const struct geoinfo_t geoinfodata []
 

Macro Definition Documentation

◆ GET_UNIX_LOCALE

#define GET_UNIX_LOCALE (   cat)
Value:
do \
if ((locale = get_locale( cat, #cat ))) \
{ \
strcpynAtoW( buffer, locale, sizeof(buffer)/sizeof(WCHAR) ); \
if (!strcmpW( buffer, ctype_buff )) lcid_##cat = lcid_LC_CTYPE; \
else { \
parse_locale_name( buffer, &locale_name ); \
lcid_##cat = locale_name.lcid; \
TRACE( "got lcid %04x (%d matches) for " #cat "=%s\n", \
} \
} while (0)
static WCHAR * get_locale(void)
Definition: builtin.c:3937
Definition: _locale.h:75
static LCID lcid_LC_CTYPE
Definition: locale.c:161
GLuint buffer
Definition: glext.h:5915
#define debugstr_a
Definition: kernel32.h:31
#define strcmpW(s1, s2)
Definition: unicode.h:44
int matches
Definition: locale.c:155
LCID lcid
Definition: locale.c:154
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ LOCALE_LOCALEINFOFLAGSMASK

#define LOCALE_LOCALEINFOFLAGSMASK
Value:
LOCALE_RETURN_NUMBER|LOCALE_RETURN_GENITIVE_NAMES)
#define LOCALE_USE_CP_ACP
Definition: winnls.h:20
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
#define LOCALE_RETURN_GENITIVE_NAMES
Definition: winnls.h:24

Definition at line 57 of file locale.c.

◆ LOCALE_NAME_USER_DEFAULT

#define LOCALE_NAME_USER_DEFAULT   NULL

Definition at line 42 of file locale.c.

◆ MB_FLAGSMASK

Definition at line 59 of file locale.c.

◆ NDEBUG

#define NDEBUG

Definition at line 26 of file locale.c.

◆ NLSRC_OFFSET

#define NLSRC_OFFSET   5000 /* FIXME */

Definition at line 53 of file locale.c.

◆ REG_SZ

#define REG_SZ   1

Definition at line 44 of file locale.c.

◆ WC_FLAGSMASK

#define WC_FLAGSMASK
Value:
#define WC_DEFAULTCHAR
Definition: unicode.h:45
#define WC_COMPOSITECHECK
Definition: unicode.h:43
#define WC_DISCARDNS
Definition: unicode.h:44
#define WC_ERR_INVALID_CHARS
Definition: unicode.h:47
#define WC_NO_BEST_FIT_CHARS
Definition: unicode.h:46
#define WC_SEPCHARS
Definition: winnls.h:219

Definition at line 60 of file locale.c.

◆ WINVER

#define WINVER   DLL_EXPORT_VERSION

Definition at line 39 of file locale.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
BASE 
TMIN 
TMAX 
SKEW 
DAMP 
INIT_BIAS 
INIT_N 

Definition at line 5676 of file locale.c.

5676 {
5677 BASE = 36,
5678 TMIN = 1,
5679 TMAX = 26,
5680 SKEW = 38,
5681 DAMP = 700,
5682 INIT_BIAS = 72,
5683 INIT_N = 128
5684};
@ INIT_N
Definition: locale.c:5683
@ DAMP
Definition: locale.c:5681
@ SKEW
Definition: locale.c:5680
@ BASE
Definition: locale.c:5677
@ TMIN
Definition: locale.c:5678
@ TMAX
Definition: locale.c:5679
@ INIT_BIAS
Definition: locale.c:5682

◆ locationkind

Enumerator
LOCATION_NATION 
LOCATION_REGION 
LOCATION_BOTH 

Definition at line 4998 of file locale.c.

4998 {
4999 LOCATION_NATION = 0,
5002};
@ LOCATION_REGION
Definition: locale.c:5000
@ LOCATION_BOTH
Definition: locale.c:5001
@ LOCATION_NATION
Definition: locale.c:4999

Function Documentation

◆ adapt()

static INT adapt ( INT  delta,
INT  numpoints,
BOOL  firsttime 
)
inlinestatic

Definition at line 5686 of file locale.c.

5687{
5688 INT k;
5689
5690 delta /= (firsttime ? DAMP : 2);
5691 delta += delta/numpoints;
5692
5693 for(k=0; delta>((BASE-TMIN)*TMAX)/2; k+=BASE)
5694 delta /= BASE-TMIN;
5695 return k+((BASE-TMIN+1)*delta)/(delta+SKEW);
5696}
int k
Definition: mpi.c:3369
int32_t INT
Definition: typedefs.h:58

Referenced by IdnToAscii(), and IdnToUnicode().

◆ CompareStringA()

INT WINAPI CompareStringA ( LCID  lcid,
DWORD  flags,
LPCSTR  str1,
INT  len1,
LPCSTR  str2,
INT  len2 
)

Definition at line 4082 of file locale.c.

4084{
4085 WCHAR *buf1W = NtCurrentTeb()->StaticUnicodeBuffer;
4086 WCHAR *buf2W = buf1W + 130;
4087 LPWSTR str1W, str2W;
4088 INT len1W = 0, len2W = 0, ret;
4089 UINT locale_cp = CP_ACP;
4090
4091 if (!str1 || !str2)
4092 {
4094 return 0;
4095 }
4096 if (len1 < 0) len1 = strlen(str1);
4097 if (len2 < 0) len2 = strlen(str2);
4098
4099 if (!(flags & LOCALE_USE_CP_ACP)) locale_cp = get_lcid_codepage( lcid );
4100
4101 if (len1)
4102 {
4103 if (len1 <= 130) len1W = MultiByteToWideChar(locale_cp, 0, str1, len1, buf1W, 130);
4104 if (len1W)
4105 str1W = buf1W;
4106 else
4107 {
4108 len1W = MultiByteToWideChar(locale_cp, 0, str1, len1, NULL, 0);
4109 str1W = HeapAlloc(GetProcessHeap(), 0, len1W * sizeof(WCHAR));
4110 if (!str1W)
4111 {
4113 return 0;
4114 }
4115 MultiByteToWideChar(locale_cp, 0, str1, len1, str1W, len1W);
4116 }
4117 }
4118 else
4119 {
4120 len1W = 0;
4121 str1W = buf1W;
4122 }
4123
4124 if (len2)
4125 {
4126 if (len2 <= 130) len2W = MultiByteToWideChar(locale_cp, 0, str2, len2, buf2W, 130);
4127 if (len2W)
4128 str2W = buf2W;
4129 else
4130 {
4131 len2W = MultiByteToWideChar(locale_cp, 0, str2, len2, NULL, 0);
4132 str2W = HeapAlloc(GetProcessHeap(), 0, len2W * sizeof(WCHAR));
4133 if (!str2W)
4134 {
4135 if (str1W != buf1W) HeapFree(GetProcessHeap(), 0, str1W);
4137 return 0;
4138 }
4139 MultiByteToWideChar(locale_cp, 0, str2, len2, str2W, len2W);
4140 }
4141 }
4142 else
4143 {
4144 len2W = 0;
4145 str2W = buf2W;
4146 }
4147
4148 ret = CompareStringEx(NULL, flags, str1W, len1W, str2W, len2W, NULL, NULL, 0);
4149
4150 if (str1W != buf1W) HeapFree(GetProcessHeap(), 0, str1W);
4151 if (str2W != buf2W) HeapFree(GetProcessHeap(), 0, str2W);
4152 return ret;
4153}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:109
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define MultiByteToWideChar
Definition: compat.h:110
static UINT get_lcid_codepage(LCID lcid)
Definition: locale.c:287
INT WINAPI CompareStringEx(LPCWSTR locale, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2, LPNLSVERSIONINFO version, LPVOID reserved, LPARAM lParam)
Definition: locale.c:4022
GLbitfield flags
Definition: glext.h:7161
#define NtCurrentTeb
unsigned int UINT
Definition: ndis.h:50
int ret
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by __crtCompareStringA(), _Locale_strcmp_auxA(), check_format(), COMCTL32_ChrCmpHelperA(), compare_line(), compare_string2(), FPropContainsProp(), get_env(), IntlStrEqWorkerA(), lstrcmpA(), lstrcmpiA(), SHLWAPI_ChrCmpHelperA(), StrCmpNA(), StrCmpNIA(), StrIsIntlEqualA(), test_CompareStringA(), test_encoders(), test_sh_new_link_info(), and UrlIsA().

◆ CompareStringEx()

INT WINAPI CompareStringEx ( LPCWSTR  locale,
DWORD  flags,
LPCWSTR  str1,
INT  len1,
LPCWSTR  str2,
INT  len2,
LPNLSVERSIONINFO  version,
LPVOID  reserved,
LPARAM  lParam 
)

Definition at line 4022 of file locale.c.

4024{
4027 DWORD semistub_flags = NORM_LINGUISTIC_CASING|LINGUISTIC_IGNORECASE|0x10000000;
4028 /* 0x10000000 is related to diacritics in Arabic, Japanese, and Hebrew */
4029 INT ret;
4030 static int once;
4031
4032 if (version) FIXME("unexpected version parameter\n");
4033 if (reserved) FIXME("unexpected reserved value\n");
4034 if (lParam) FIXME("unexpected lParam\n");
4035
4036 if (!str1 || !str2)
4037 {
4039 return 0;
4040 }
4041
4042 if (flags & ~(supported_flags|semistub_flags))
4043 {
4045 return 0;
4046 }
4047
4048 if (flags & semistub_flags)
4049 {
4050 if (!once++)
4051 FIXME("semi-stub behavior for flag(s) 0x%x\n", flags & semistub_flags);
4052 }
4053
4054 if (len1 < 0) len1 = strlenW(str1);
4055 if (len2 < 0) len2 = strlenW(str2);
4056
4057 ret = wine_compare_string(flags, str1, len1, str2, len2);
4058
4059 if (ret) /* need to translate result */
4060 return (ret < 0) ? CSTR_LESS_THAN : CSTR_GREATER_THAN;
4061 return CSTR_EQUAL;
4062}
#define FIXME(fmt,...)
Definition: precomp.h:53
LPARAM lParam
Definition: combotst.c:139
static const WCHAR version[]
Definition: asmname.c:66
int wine_compare_string(int flags, const WCHAR *str1, int len1, const WCHAR *str2, int len2)
Definition: sortkey.c:358
r reserved
Definition: btrfs.c:3006
unsigned long DWORD
Definition: ntddk_ex.h:95
#define strlenW(s)
Definition: unicode.h:34
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583
#define NORM_IGNORECASE
Definition: winnls.h:176
#define SORT_STRINGSORT
Definition: winnls.h:183
#define LINGUISTIC_IGNORECASE
Definition: winnls.h:181
#define NORM_IGNOREKANATYPE
Definition: winnls.h:177
#define NORM_LINGUISTIC_CASING
Definition: winnls.h:182
#define CSTR_EQUAL
Definition: winnls.h:456
#define NORM_IGNORENONSPACE
Definition: winnls.h:178
#define NORM_IGNORESYMBOLS
Definition: winnls.h:179
#define NORM_IGNOREWIDTH
Definition: winnls.h:180
#define CSTR_LESS_THAN
Definition: winnls.h:455
#define CSTR_GREATER_THAN
Definition: winnls.h:457

Referenced by CompareStringA(), CompareStringW(), and InitFunctionPointers().

◆ CompareStringW()

◆ convert_default_lcid()

static LCID convert_default_lcid ( LCID  lcid,
LCTYPE  lctype 
)
static

Definition at line 586 of file locale.c.

587{
588 if (lcid == LOCALE_SYSTEM_DEFAULT ||
589 lcid == LOCALE_USER_DEFAULT ||
590 lcid == LOCALE_NEUTRAL)
591 {
592 LCID default_id = 0;
593
594 switch(lctype & 0xffff)
595 {
596 case LOCALE_SSORTNAME:
597 default_id = lcid_LC_COLLATE;
598 break;
599
603 case LOCALE_IDEFAULTEBCDICCODEPAGE:
606 default_id = lcid_LC_CTYPE;
607 break;
608
610 case LOCALE_ICURRENCY:
612 case LOCALE_INEGCURR:
619 case LOCALE_SCURRENCY:
624 case LOCALE_SNATIVECURRNAME:
625 default_id = lcid_LC_MONETARY;
626 break;
627
628 case LOCALE_IDIGITS:
629 case LOCALE_IDIGITSUBSTITUTION:
630 case LOCALE_ILZERO:
632 case LOCALE_SDECIMAL:
633 case LOCALE_SGROUPING:
634 //case LOCALE_SNAN:
637 //case LOCALE_SNEGINFINITY:
638 //case LOCALE_SPOSINFINITY:
640 case LOCALE_STHOUSAND:
641 default_id = lcid_LC_NUMERIC;
642 break;
643
645 case LOCALE_ICENTURY:
646 case LOCALE_IDATE:
647 case LOCALE_IDAYLZERO:
650 case LOCALE_ILDATE:
651 case LOCALE_IMONLZERO:
653 case LOCALE_ITIME:
655 case LOCALE_ITLZERO:
656 case LOCALE_S1159:
657 case LOCALE_S2359:
678 case LOCALE_SDATE:
679 case LOCALE_SDAYNAME1:
680 case LOCALE_SDAYNAME2:
681 case LOCALE_SDAYNAME3:
682 case LOCALE_SDAYNAME4:
683 case LOCALE_SDAYNAME5:
684 case LOCALE_SDAYNAME6:
685 case LOCALE_SDAYNAME7:
686 //case LOCALE_SDURATION:
687 case LOCALE_SLONGDATE:
702 //case LOCALE_SSHORTESTDAYNAME1:
703 //case LOCALE_SSHORTESTDAYNAME2:
704 //case LOCALE_SSHORTESTDAYNAME3:
705 //case LOCALE_SSHORTESTDAYNAME4:
706 //case LOCALE_SSHORTESTDAYNAME5:
707 //case LOCALE_SSHORTESTDAYNAME6:
708 //case LOCALE_SSHORTESTDAYNAME7:
709 case LOCALE_STIME:
711 case LOCALE_SYEARMONTH:
712 default_id = lcid_LC_TIME;
713 break;
714
715 case LOCALE_IPAPERSIZE:
716 default_id = lcid_LC_PAPER;
717 break;
718
719 case LOCALE_IMEASURE:
720 default_id = lcid_LC_MEASUREMENT;
721 break;
722
723 case LOCALE_ICOUNTRY:
724 default_id = lcid_LC_TELEPHONE;
725 break;
726 }
727 if (default_id) lcid = default_id;
728 }
729 return ConvertDefaultLocale( lcid );
730}
static LCID lcid_LC_MONETARY
Definition: locale.c:163
static LCID lcid_LC_TIME
Definition: locale.c:165
static LCID lcid_LC_NUMERIC
Definition: locale.c:164
static LCID lcid_LC_COLLATE
Definition: locale.c:160
static LCID lcid_LC_MEASUREMENT
Definition: locale.c:167
static LCID lcid_LC_TELEPHONE
Definition: locale.c:168
static LCID lcid_LC_PAPER
Definition: locale.c:166
LCID WINAPI ConvertDefaultLocale(LCID lcid)
Definition: locale.c:2876
#define LOCALE_NEUTRAL
#define LOCALE_USER_DEFAULT
#define LOCALE_SYSTEM_DEFAULT
DWORD LCID
Definition: nls.h:13
#define LOCALE_SABBREVMONTHNAME10
Definition: winnls.h:113
#define LOCALE_SMONTHNAME12
Definition: winnls.h:102
#define LOCALE_ICURRDIGITS
Definition: winnls.h:54
#define LOCALE_IDEFAULTCODEPAGE
Definition: winnls.h:37
#define LOCALE_SMONTHNAME5
Definition: winnls.h:95
#define LOCALE_SDATE
Definition: winnls.h:58
#define LOCALE_SDAYNAME5
Definition: winnls.h:81
#define LOCALE_SABBREVMONTHNAME9
Definition: winnls.h:112
#define LOCALE_SABBREVMONTHNAME11
Definition: winnls.h:114
#define LOCALE_SABBREVDAYNAME5
Definition: winnls.h:88
#define LOCALE_SABBREVDAYNAME2
Definition: winnls.h:85
#define LOCALE_INEGSEPBYSPACE
Definition: winnls.h:124
#define LOCALE_SABBREVMONTHNAME2
Definition: winnls.h:105
#define LOCALE_INEGSIGNPOSN
Definition: winnls.h:120
#define LOCALE_IDEFAULTUNIXCODEPAGE
Definition: winnls.h:174
#define LOCALE_SMONTHNAME13
Definition: winnls.h:103
#define LOCALE_SGROUPING
Definition: winnls.h:44
#define LOCALE_SMONTHNAME3
Definition: winnls.h:93
#define LOCALE_ICOUNTRY
Definition: winnls.h:30
#define LOCALE_SDECIMAL
Definition: winnls.h:42
#define LOCALE_SMONTHNAME11
Definition: winnls.h:101
#define LOCALE_SMONTHNAME8
Definition: winnls.h:98
#define LOCALE_IDATE
Definition: winnls.h:63
#define LOCALE_SMONTHNAME4
Definition: winnls.h:94
#define LOCALE_FONTSIGNATURE
Definition: winnls.h:125
#define LOCALE_SABBREVMONTHNAME13
Definition: winnls.h:116
#define LOCALE_IFIRSTWEEKOFYEAR
Definition: winnls.h:76
#define LOCALE_SDAYNAME1
Definition: winnls.h:77
#define LOCALE_IMEASURE
Definition: winnls.h:41
#define LOCALE_SLONGDATE
Definition: winnls.h:61
#define LOCALE_SMONTHNAME7
Definition: winnls.h:97
#define LOCALE_IINTLCURRDIGITS
Definition: winnls.h:55
#define LOCALE_S1159
Definition: winnls.h:71
#define LOCALE_SSHORTDATE
Definition: winnls.h:60
#define LOCALE_IPOSSYMPRECEDES
Definition: winnls.h:121
#define LOCALE_IDAYLZERO
Definition: winnls.h:69
#define LOCALE_SABBREVMONTHNAME4
Definition: winnls.h:107
#define LOCALE_SPOSITIVESIGN
Definition: winnls.h:117
#define LOCALE_SABBREVDAYNAME4
Definition: winnls.h:87
#define LOCALE_SMONDECIMALSEP
Definition: winnls.h:51
#define LOCALE_ITIME
Definition: winnls.h:65
#define LOCALE_ICURRENCY
Definition: winnls.h:56
#define LOCALE_SMONTHNAME1
Definition: winnls.h:91
#define LOCALE_SABBREVMONTHNAME3
Definition: winnls.h:106
#define LOCALE_ITLZERO
Definition: winnls.h:68
#define LOCALE_INEGSYMPRECEDES
Definition: winnls.h:123
#define LOCALE_SMONTHOUSANDSEP
Definition: winnls.h:52
#define LOCALE_SDAYNAME7
Definition: winnls.h:83
#define LOCALE_IPOSSIGNPOSN
Definition: winnls.h:119
#define LOCALE_SDAYNAME2
Definition: winnls.h:78
#define LOCALE_SABBREVMONTHNAME1
Definition: winnls.h:104
#define LOCALE_IOPTIONALCALENDAR
Definition: winnls.h:74
#define LOCALE_IDIGITS
Definition: winnls.h:45
#define LOCALE_STHOUSAND
Definition: winnls.h:43
#define LOCALE_IDEFAULTANSICODEPAGE
Definition: winnls.h:38
#define LOCALE_SABBREVDAYNAME6
Definition: winnls.h:89
#define LOCALE_SMONTHNAME2
Definition: winnls.h:92
#define LOCALE_STIMEFORMAT
Definition: winnls.h:62
#define LOCALE_SABBREVDAYNAME1
Definition: winnls.h:84
#define LOCALE_IFIRSTDAYOFWEEK
Definition: winnls.h:75
#define LOCALE_SABBREVMONTHNAME6
Definition: winnls.h:109
#define LOCALE_SMONTHNAME6
Definition: winnls.h:96
#define LOCALE_STIME
Definition: winnls.h:59
#define LOCALE_INEGNUMBER
Definition: winnls.h:47
#define LOCALE_SNEGATIVESIGN
Definition: winnls.h:118
#define LOCALE_SDAYNAME3
Definition: winnls.h:79
#define LOCALE_S2359
Definition: winnls.h:72
#define LOCALE_SNATIVEDIGITS
Definition: winnls.h:48
#define LOCALE_SABBREVDAYNAME3
Definition: winnls.h:86
#define LOCALE_ILZERO
Definition: winnls.h:46
#define LOCALE_SABBREVMONTHNAME5
Definition: winnls.h:108
#define LOCALE_SABBREVMONTHNAME7
Definition: winnls.h:110
#define LOCALE_ICALENDARTYPE
Definition: winnls.h:73
#define LOCALE_SINTLSYMBOL
Definition: winnls.h:50
#define LOCALE_SABBREVMONTHNAME8
Definition: winnls.h:111
#define LOCALE_SMONGROUPING
Definition: winnls.h:53
#define LOCALE_SDAYNAME4
Definition: winnls.h:80
#define LOCALE_SCURRENCY
Definition: winnls.h:49
#define LOCALE_SMONTHNAME10
Definition: winnls.h:100
#define LOCALE_INEGCURR
Definition: winnls.h:57
#define LOCALE_ILDATE
Definition: winnls.h:64
#define LOCALE_SMONTHNAME9
Definition: winnls.h:99
#define LOCALE_IPOSSEPBYSPACE
Definition: winnls.h:122
#define LOCALE_ICENTURY
Definition: winnls.h:67
#define LOCALE_IMONLZERO
Definition: winnls.h:70
#define LOCALE_SABBREVMONTHNAME12
Definition: winnls.h:115
#define LOCALE_IDEFAULTMACCODEPAGE
Definition: winnls.h:39
#define LOCALE_SDAYNAME6
Definition: winnls.h:82
#define LOCALE_ITIMEMARKPOSN
Definition: winnls.h:66
#define LOCALE_SABBREVDAYNAME7
Definition: winnls.h:90

Referenced by GetLocaleInfoW().

◆ ConvertDefaultLocale()

LCID WINAPI ConvertDefaultLocale ( LCID  lcid)

Definition at line 2876 of file locale.c.

2877{
2878 LANGID langid;
2879
2880 switch (lcid)
2881 {
2882 case LOCALE_INVARIANT:
2883 /* keep as-is */
2884 break;
2886 lcid = GetSystemDefaultLCID();
2887 break;
2889 case LOCALE_NEUTRAL:
2890 lcid = GetUserDefaultLCID();
2891 break;
2892 default:
2893 /* Replace SUBLANG_NEUTRAL with SUBLANG_DEFAULT */
2894 langid = LANGIDFROMLCID(lcid);
2896 {
2898 lcid = MAKELCID(langid, SORTIDFROMLCID(lcid));
2899 }
2900 }
2901 return lcid;
2902}
static LANGID get_default_sublang(LANGID lang)
Definition: locale.c:366
LCID WINAPI GetUserDefaultLCID(void)
Definition: locale.c:1210
LCID WINAPI GetSystemDefaultLCID(void)
Definition: locale.c:1229
USHORT LANGID
Definition: mui.h:9
LANGID langid
Definition: msctf.idl:644
#define LOCALE_INVARIANT
#define SORTIDFROMLCID(lcid)
#define MAKELCID(lgid, srtid)
#define SUBLANGID(l)
Definition: nls.h:17
#define LANGIDFROMLCID(l)
Definition: nls.h:18
#define SUBLANG_NEUTRAL
Definition: nls.h:167

Referenced by convert_default_lcid(), GetLocalisedText(), LHashValOfNameSysA(), NLS_IsUnicodeOnlyLcid(), ScriptRecordDigitSubstitution(), SetThreadLocale(), test_ConvertDefaultLocale(), VarBoolFromStr(), and VarBstrFromBool().

◆ create_registry_key()

static HANDLE create_registry_key ( void  )
inlinestatic

Definition at line 765 of file locale.c.

766{
767 static const WCHAR cplW[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l',0};
768 static const WCHAR intlW[] = {'I','n','t','e','r','n','a','t','i','o','n','a','l',0};
771 HANDLE cpl_key, hkey = 0;
772
773 if (RtlOpenCurrentUser( KEY_ALL_ACCESS, &hkey ) != STATUS_SUCCESS) return 0;
774
775 attr.Length = sizeof(attr);
776 attr.RootDirectory = hkey;
777 attr.ObjectName = &nameW;
778 attr.Attributes = 0;
779 attr.SecurityDescriptor = NULL;
780 attr.SecurityQualityOfService = NULL;
781 RtlInitUnicodeString( &nameW, cplW );
782
783 if (!NtCreateKey( &cpl_key, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL ))
784 {
785 NtClose( attr.RootDirectory );
786 attr.RootDirectory = cpl_key;
787 RtlInitUnicodeString( &nameW, intlW );
788 if (NtCreateKey( &hkey, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL )) hkey = 0;
789 }
790 NtClose( attr.RootDirectory );
791 return hkey;
792}
static const WCHAR nameW[]
Definition: main.c:49
NTSYSAPI NTSTATUS NTAPI RtlOpenCurrentUser(_In_ ACCESS_MASK DesiredAccess, _Out_ PHANDLE KeyHandle)
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
NTSTATUS NTAPI NtCreateKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG TitleIndex, IN PUNICODE_STRING Class OPTIONAL, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
Definition: ntapi.c:240
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: cookie.c:202

Referenced by get_registry_locale_info(), GetUserGeoID(), LOCALE_InitRegistry(), SetLocaleInfoW(), and SetUserGeoID().

◆ DEBUG_CHANNEL()

DEBUG_CHANNEL ( nls  )

◆ enum_lang_proc_a()

static BOOL CALLBACK enum_lang_proc_a ( HMODULE  hModule,
LPCSTR  type,
LPCSTR  name,
WORD  LangID,
LONG_PTR  lParam 
)
static

Definition at line 2950 of file locale.c.

2952{
2953 LOCALE_ENUMPROCA lpfnLocaleEnum = (LOCALE_ENUMPROCA)lParam;
2954 char buf[20];
2955
2956 sprintf(buf, "%08x", (UINT)LangID);
2957 return lpfnLocaleEnum( buf );
2958}
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define sprintf(buf, format,...)
Definition: sprintf.c:55
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1083
BOOL(CALLBACK * LOCALE_ENUMPROCA)(LPSTR)
Definition: winnls.h:537

Referenced by EnumSystemLocalesA().

◆ enum_lang_proc_w()

static BOOL CALLBACK enum_lang_proc_w ( HMODULE  hModule,
LPCWSTR  type,
LPCWSTR  name,
WORD  LangID,
LONG_PTR  lParam 
)
static

Definition at line 2960 of file locale.c.

2962{
2963 static const WCHAR formatW[] = {'%','0','8','x',0};
2964 LOCALE_ENUMPROCW lpfnLocaleEnum = (LOCALE_ENUMPROCW)lParam;
2965 WCHAR buf[20];
2966 sprintfW( buf, formatW, (UINT)LangID );
2967 return lpfnLocaleEnum( buf );
2968}
#define sprintfW
Definition: unicode.h:64
BOOL(CALLBACK * LOCALE_ENUMPROCW)(LPWSTR)
Definition: winnls.h:538

Referenced by EnumSystemLocalesW().

◆ enum_locale_ex_proc()

static BOOL CALLBACK enum_locale_ex_proc ( HMODULE  module,
LPCWSTR  type,
LPCWSTR  name,
WORD  lang,
LONG_PTR  lparam 
)
static

Definition at line 3015 of file locale.c.

3017{
3019 WCHAR buffer[256];
3020 DWORD neutral;
3021 unsigned int flags;
3022
3024 buffer, sizeof(buffer) / sizeof(WCHAR) );
3026 LOCALE_INEUTRAL | LOCALE_NOUSEROVERRIDE | LOCALE_RETURN_NUMBER,
3027 (LPWSTR)&neutral, sizeof(neutral) / sizeof(WCHAR) ))
3028 neutral = 0;
3031 if (data->flags && !(data->flags & flags)) return TRUE;
3032 return data->proc( buffer, flags, data->lparam );
3033}
@ lparam
Definition: SystemMenu.c:31
#define TRUE
Definition: types.h:120
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1665
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define SORT_DEFAULT
static const WCHAR lang[]
Definition: wbemdisp.c:287
#define LOCALE_NEUTRALDATA
Definition: winnls.h:210
#define LOCALE_SNAME
Definition: winnls.h:130
#define LOCALE_SPECIFICDATA
Definition: winnls.h:211
#define LOCALE_INEUTRAL
Definition: winnls.h:156
#define LOCALE_WINDOWS
Definition: winnls.h:206

Referenced by EnumSystemLocalesEx().

◆ enum_uilang_proc_a()

static BOOL CALLBACK enum_uilang_proc_a ( HMODULE  hModule,
LPCSTR  type,
LPCSTR  name,
WORD  LangID,
LONG_PTR  lParam 
)
static

Definition at line 4920 of file locale.c.

4922{
4924 char buf[20];
4925
4926 sprintf(buf, "%08x", (UINT)LangID);
4927 return enum_uilang->u.procA( buf, enum_uilang->param );
4928}
UILANGUAGE_ENUMPROCA procA
Definition: locale.c:4913
union ENUM_UILANG_CALLBACK::@465 u

Referenced by EnumUILanguagesA().

◆ enum_uilang_proc_w()

static BOOL CALLBACK enum_uilang_proc_w ( HMODULE  hModule,
LPCWSTR  type,
LPCWSTR  name,
WORD  LangID,
LONG_PTR  lParam 
)
static

Definition at line 4930 of file locale.c.

4932{
4933 static const WCHAR formatW[] = {'%','0','8','x',0};
4935 WCHAR buf[20];
4936
4937 sprintfW( buf, formatW, (UINT)LangID );
4938 return enum_uilang->u.procW( buf, enum_uilang->param );
4939}
UILANGUAGE_ENUMPROCW procW
Definition: locale.c:4914

Referenced by EnumUILanguagesW().

◆ EnumLanguageGroupLocalesA()

BOOL WINAPI EnumLanguageGroupLocalesA ( LANGGROUPLOCALE_ENUMPROCA  pLangGrpLcEnumProc,
LGRPID  lgrpid,
DWORD  dwFlags,
LONG_PTR  lParam 
)

Definition at line 4774 of file locale.c.

4776{
4778
4779 TRACE("(%p,0x%08X,0x%08X,0x%08lX)\n", pLangGrpLcEnumProc, lgrpid, dwFlags, lParam);
4780
4781 callbacks.procA = pLangGrpLcEnumProc;
4782 callbacks.procW = NULL;
4783 callbacks.dwFlags = dwFlags;
4784 callbacks.lgrpid = lgrpid;
4785 callbacks.lParam = lParam;
4786
4787 return NLS_EnumLanguageGroupLocales( pLangGrpLcEnumProc ? &callbacks : NULL );
4788}
static BOOL NLS_EnumLanguageGroupLocales(ENUMLANGUAGEGROUPLOCALE_CALLBACKS *lpProcs)
Definition: locale.c:4672
#define TRACE(s)
Definition: solgame.cpp:4
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
static int callbacks
Definition: xmllint.c:838

Referenced by InitFunctionPointers(), and test_digit_substitution().

◆ EnumLanguageGroupLocalesW()

BOOL WINAPI EnumLanguageGroupLocalesW ( LANGGROUPLOCALE_ENUMPROCW  pLangGrpLcEnumProc,
LGRPID  lgrpid,
DWORD  dwFlags,
LONG_PTR  lParam 
)

Definition at line 4795 of file locale.c.

4797{
4799
4800 TRACE("(%p,0x%08X,0x%08X,0x%08lX)\n", pLangGrpLcEnumProc, lgrpid, dwFlags, lParam);
4801
4802 callbacks.procA = NULL;
4803 callbacks.procW = pLangGrpLcEnumProc;
4804 callbacks.dwFlags = dwFlags;
4805 callbacks.lgrpid = lgrpid;
4806 callbacks.lParam = lParam;
4807
4808 return NLS_EnumLanguageGroupLocales( pLangGrpLcEnumProc ? &callbacks : NULL );
4809}

◆ EnumSystemCodePagesA()

BOOL WINAPI EnumSystemCodePagesA ( CODEPAGE_ENUMPROCA  lpfnCodePageEnum,
DWORD  flags 
)

Definition at line 2273 of file locale.c.

2274{
2275 const union cptable *table;
2276 char buffer[10];
2277 int index = 0;
2278
2279 for (;;)
2280 {
2281 if (!(table = wine_cp_enum_table( index++ ))) break;
2282 sprintf( buffer, "%d", table->info.codepage );
2283 if (!lpfnCodePageEnum( buffer )) break;
2284 }
2285 return TRUE;
2286}
GLuint index
Definition: glext.h:6031
const union cptable * wine_cp_enum_table(unsigned int index)
Definition: cptable.c:203

◆ EnumSystemCodePagesW()

BOOL WINAPI EnumSystemCodePagesW ( CODEPAGE_ENUMPROCW  lpfnCodePageEnum,
DWORD  flags 
)

Definition at line 2294 of file locale.c.

2295{
2296 const union cptable *table;
2297 WCHAR buffer[10], *p;
2298 int page, index = 0;
2299
2300 for (;;)
2301 {
2302 if (!(table = wine_cp_enum_table( index++ ))) break;
2303 p = buffer + sizeof(buffer)/sizeof(WCHAR);
2304 *--p = 0;
2305 page = table->info.codepage;
2306 do
2307 {
2308 *--p = '0' + (page % 10);
2309 page /= 10;
2310 } while( page );
2311 if (!lpfnCodePageEnum( p )) break;
2312 }
2313 return TRUE;
2314}
GLfloat GLfloat p
Definition: glext.h:8902
Definition: module.h:576

Referenced by InitCodePagesList().

◆ EnumSystemGeoID()

BOOL WINAPI EnumSystemGeoID ( GEOCLASS  geoclass,
GEOID  parent,
GEO_ENUMPROC  enumproc 
)

Definition at line 5609 of file locale.c.

5610{
5611 INT i;
5612
5613 TRACE("(%d, %d, %p)\n", geoclass, parent, enumproc);
5614
5615 if (!enumproc) {
5617 return FALSE;
5618 }
5619
5620 if (geoclass != GEOCLASS_NATION && geoclass != GEOCLASS_REGION) {
5622 return FALSE;
5623 }
5624
5625 for (i = 0; i < sizeof(geoinfodata)/sizeof(struct geoinfo_t); i++) {
5626 const struct geoinfo_t *ptr = &geoinfodata[i];
5627
5628 if (geoclass == GEOCLASS_NATION && (ptr->kind == LOCATION_REGION))
5629 continue;
5630
5631 if (geoclass == GEOCLASS_REGION && (ptr->kind == LOCATION_NATION))
5632 continue;
5633
5634 if (parent && ptr->parent != parent)
5635 continue;
5636
5637 if (!enumproc(ptr->id))
5638 return TRUE;
5639 }
5640
5641 return TRUE;
5642}
#define FALSE
Definition: types.h:117
static const struct geoinfo_t geoinfodata[]
Definition: locale.c:5013
r parent
Definition: btrfs.c:3010
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static PVOID ptr
Definition: dispmode.c:27
@ GEOCLASS_REGION
Definition: winnls.h:556
@ GEOCLASS_NATION
Definition: winnls.h:555

Referenced by CreateLocationsList(), and InitFunctionPointers().

◆ EnumSystemLanguageGroupsA()

BOOL WINAPI EnumSystemLanguageGroupsA ( LANGUAGEGROUP_ENUMPROCA  pLangGrpEnumProc,
DWORD  dwFlags,
LONG_PTR  lParam 
)

Definition at line 4575 of file locale.c.

4577{
4579
4580 TRACE("(%p,0x%08X,0x%08lX)\n", pLangGrpEnumProc, dwFlags, lParam);
4581
4582 procs.procA = pLangGrpEnumProc;
4583 procs.procW = NULL;
4584 procs.dwFlags = dwFlags;
4585 procs.lParam = lParam;
4586
4587 return NLS_EnumSystemLanguageGroups( pLangGrpEnumProc ? &procs : NULL);
4588}
static BOOL NLS_EnumSystemLanguageGroups(ENUMLANGUAGEGROUP_CALLBACKS *lpProcs)
Definition: locale.c:4476
LANGUAGEGROUP_ENUMPROCW procW
Definition: locale.c:4470
LANGUAGEGROUP_ENUMPROCA procA
Definition: locale.c:4469

Referenced by InitFunctionPointers().

◆ EnumSystemLanguageGroupsW()

BOOL WINAPI EnumSystemLanguageGroupsW ( LANGUAGEGROUP_ENUMPROCW  pLangGrpEnumProc,
DWORD  dwFlags,
LONG_PTR  lParam 
)

Definition at line 4595 of file locale.c.

4597{
4599
4600 TRACE("(%p,0x%08X,0x%08lX)\n", pLangGrpEnumProc, dwFlags, lParam);
4601
4602 procs.procA = NULL;
4603 procs.procW = pLangGrpEnumProc;
4604 procs.dwFlags = dwFlags;
4605 procs.lParam = lParam;
4606
4607 return NLS_EnumSystemLanguageGroups( pLangGrpEnumProc ? &procs : NULL);
4608}

◆ EnumSystemLocalesA()

BOOL WINAPI EnumSystemLocalesA ( LOCALE_ENUMPROCA  lpfnLocaleEnum,
DWORD  dwFlags 
)

Definition at line 2983 of file locale.c.

2984{
2985 TRACE("(%p,%08x)\n", lpfnLocaleEnum, dwFlags);
2988 (LONG_PTR)lpfnLocaleEnum);
2989 return TRUE;
2990}
BOOL WINAPI EnumResourceLanguagesA(HMODULE hmod, LPCSTR type, LPCSTR name, ENUMRESLANGPROCA lpfun, LONG_PTR lparam)
Definition: res.c:428
static BOOL CALLBACK enum_lang_proc_a(HMODULE hModule, LPCSTR type, LPCSTR name, WORD LangID, LONG_PTR lParam)
Definition: locale.c:2950
HMODULE kernel32_handle
Definition: dllmain.c:26
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define RT_STRING
Definition: pedump.c:368
#define LOCALE_ILANGUAGE
Definition: winnls.h:25
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182

Referenced by __GetLCID().

◆ EnumSystemLocalesEx()

BOOL WINAPI EnumSystemLocalesEx ( LOCALE_ENUMPROCEX  proc,
DWORD  flags,
LPARAM  lparam,
LPVOID  reserved 
)

Definition at line 3038 of file locale.c.

3039{
3041
3042 if (reserved)
3043 {
3045 return FALSE;
3046 }
3047 data.proc = proc;
3048 data.flags = flags;
3049 data.lparam = lparam;
3053 return TRUE;
3054}
BOOL WINAPI EnumResourceLanguagesW(HMODULE hmod, LPCWSTR type, LPCWSTR name, ENUMRESLANGPROCW lpfun, LONG_PTR lparam)
Definition: res.c:480
static BOOL CALLBACK enum_locale_ex_proc(HMODULE module, LPCWSTR type, LPCWSTR name, WORD lang, LONG_PTR lparam)
Definition: locale.c:3015
static HANDLE proc()
Definition: pdb.c:34
#define MAKEINTRESOURCE
Definition: winuser.h:591
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by InitFunctionPointers().

◆ EnumSystemLocalesW()

BOOL WINAPI EnumSystemLocalesW ( LOCALE_ENUMPROCW  lpfnLocaleEnum,
DWORD  dwFlags 
)

Definition at line 2998 of file locale.c.

2999{
3000 TRACE("(%p,%08x)\n", lpfnLocaleEnum, dwFlags);
3003 (LONG_PTR)lpfnLocaleEnum);
3004 return TRUE;
3005}
static BOOL CALLBACK enum_lang_proc_w(HMODULE hModule, LPCWSTR type, LPCWSTR name, WORD LangID, LONG_PTR lParam)
Definition: locale.c:2960

Referenced by CreateLanguagesList(), CreateSortList(), EnumRfc1766_create(), InitLanguagesList(), and IsSortPageNeeded().

◆ EnumUILanguagesA()

BOOL WINAPI EnumUILanguagesA ( UILANGUAGE_ENUMPROCA  pUILangEnumProc,
DWORD  dwFlags,
LONG_PTR  lParam 
)

Definition at line 4944 of file locale.c.

4945{
4946 ENUM_UILANG_CALLBACK enum_uilang;
4947
4948 TRACE("%p, %x, %lx\n", pUILangEnumProc, dwFlags, lParam);
4949
4950 if(!pUILangEnumProc) {
4952 return FALSE;
4953 }
4954 if(dwFlags) {
4956 return FALSE;
4957 }
4958
4959 enum_uilang.u.procA = pUILangEnumProc;
4960 enum_uilang.flags = dwFlags;
4961 enum_uilang.param = lParam;
4962
4965 (LONG_PTR)&enum_uilang);
4966 return TRUE;
4967}
static BOOL CALLBACK enum_uilang_proc_a(HMODULE hModule, LPCSTR type, LPCSTR name, WORD LangID, LONG_PTR lParam)
Definition: locale.c:4920

Referenced by InitFunctionPointers().

◆ EnumUILanguagesW()

BOOL WINAPI EnumUILanguagesW ( UILANGUAGE_ENUMPROCW  pUILangEnumProc,
DWORD  dwFlags,
LONG_PTR  lParam 
)

Definition at line 4972 of file locale.c.

4973{
4974 ENUM_UILANG_CALLBACK enum_uilang;
4975
4976 TRACE("%p, %x, %lx\n", pUILangEnumProc, dwFlags, lParam);
4977
4978
4979 if(!pUILangEnumProc) {
4981 return FALSE;
4982 }
4983 if(dwFlags) {
4985 return FALSE;
4986 }
4987
4988 enum_uilang.u.procW = pUILangEnumProc;
4989 enum_uilang.flags = dwFlags;
4990 enum_uilang.param = lParam;
4991
4994 (LONG_PTR)&enum_uilang);
4995 return TRUE;
4996}
static BOOL CALLBACK enum_uilang_proc_w(HMODULE hModule, LPCWSTR type, LPCWSTR name, WORD LangID, LONG_PTR lParam)
Definition: locale.c:4930

◆ FoldStringA()

INT WINAPI FoldStringA ( DWORD  dwFlags,
LPCSTR  src,
INT  srclen,
LPSTR  dst,
INT  dstlen 
)

Definition at line 3920 of file locale.c.

3922{
3923 INT ret = 0, srclenW = 0;
3924 WCHAR *srcW = NULL, *dstW = NULL;
3925
3926 if (!src || !srclen || dstlen < 0 || (dstlen && !dst) || src == dst)
3927 {
3929 return 0;
3930 }
3931
3933 src, srclen, NULL, 0);
3934 srcW = HeapAlloc(GetProcessHeap(), 0, srclenW * sizeof(WCHAR));
3935
3936 if (!srcW)
3937 {
3939 goto FoldStringA_exit;
3940 }
3941
3943 src, srclen, srcW, srclenW);
3944
3945 dwFlags = (dwFlags & ~MAP_PRECOMPOSED) | MAP_FOLDCZONE;
3946
3947 ret = FoldStringW(dwFlags, srcW, srclenW, NULL, 0);
3948 if (ret && dstlen)
3949 {
3950 dstW = HeapAlloc(GetProcessHeap(), 0, ret * sizeof(WCHAR));
3951
3952 if (!dstW)
3953 {
3955 goto FoldStringA_exit;
3956 }
3957
3958 ret = FoldStringW(dwFlags, srcW, srclenW, dstW, ret);
3959 if (!WideCharToMultiByte(CP_ACP, 0, dstW, ret, dst, dstlen, NULL, NULL))
3960 {
3961 ret = 0;
3963 }
3964 }
3965
3966 HeapFree(GetProcessHeap(), 0, dstW);
3967
3968FoldStringA_exit:
3969 HeapFree(GetProcessHeap(), 0, srcW);
3970 return ret;
3971}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define WideCharToMultiByte
Definition: compat.h:111
INT WINAPI FoldStringW(DWORD dwFlags, LPCWSTR src, INT srclen, LPWSTR dst, INT dstlen)
Definition: locale.c:3978
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define MB_COMPOSITE
Definition: unicode.h:40
static DWORD LPDWORD LPCSTR DWORD srclen
Definition: directory.c:52
static DWORD dstlen
Definition: directory.c:51
#define MAP_COMPOSITE
Definition: winnls.h:216
#define MAP_FOLDCZONE
Definition: winnls.h:213

Referenced by InitFunctionPointers().

◆ FoldStringW()

INT WINAPI FoldStringW ( DWORD  dwFlags,
LPCWSTR  src,
INT  srclen,
LPWSTR  dst,
INT  dstlen 
)

Definition at line 3978 of file locale.c.

3980{
3981 int ret;
3982
3983 switch (dwFlags & (MAP_COMPOSITE|MAP_PRECOMPOSED|MAP_EXPAND_LIGATURES))
3984 {
3985 case 0:
3986 if (dwFlags)
3987 break;
3988 /* Fall through for dwFlags == 0 */
3990 case MAP_PRECOMPOSED|MAP_EXPAND_LIGATURES:
3991 case MAP_COMPOSITE|MAP_EXPAND_LIGATURES:
3993 return 0;
3994 }
3995
3996 if (!src || !srclen || dstlen < 0 || (dstlen && !dst) || src == dst)
3997 {
3999 return 0;
4000 }
4001
4003 if (!ret)
4005 return ret;
4006}
int wine_fold_string(int flags, const WCHAR *src, int srclen, WCHAR *dst, int dstlen)
Definition: fold.c:118
#define MAP_PRECOMPOSED
Definition: winnls.h:215

Referenced by FoldStringA(), IdnToNameprepUnicode(), and InitFunctionPointers().

◆ get_codepage_table()

static const union cptable * get_codepage_table ( unsigned int  codepage)
static

Definition at line 301 of file locale.c.

302{
303 const union cptable *ret = NULL;
304
305 assert( ansi_cptable ); /* init must have been done already */
306
307 switch(codepage)
308 {
309 case CP_ACP:
310 return ansi_cptable;
311 case CP_OEMCP:
312 return oem_cptable;
313 case CP_MACCP:
314 return mac_cptable;
315 case CP_UTF7:
316 case CP_UTF8:
317 break;
318 case CP_THREAD_ACP:
319 if (NtCurrentTeb()->CurrentLocale == GetUserDefaultLCID()) return ansi_cptable;
320 codepage = get_lcid_codepage( NtCurrentTeb()->CurrentLocale );
321 if (!codepage) return ansi_cptable;
322 /* fall through */
323 default:
324 if (codepage == ansi_cptable->info.codepage) return ansi_cptable;
325 if (codepage == oem_cptable->info.codepage) return oem_cptable;
326 if (codepage == mac_cptable->info.codepage) return mac_cptable;
328 break;
329 }
330 return ret;
331}
static const union cptable * oem_cptable
Definition: locale.c:65
static const union cptable * ansi_cptable
Definition: locale.c:64
static const union cptable * mac_cptable
Definition: locale.c:66
#define assert(x)
Definition: debug.h:53
const union cptable * wine_cp_get_table(unsigned int codepage)
Definition: cptable.c:192
#define CP_UTF8
Definition: nls.h:20
struct cp_info info
Definition: unicode.h:96
int codepage
Definition: win_iconv.c:156
#define CP_THREAD_ACP
Definition: winnls.h:233
#define CP_OEMCP
Definition: winnls.h:231
#define CP_UTF7
Definition: winnls.h:235
#define CP_MACCP
Definition: winnls.h:232

Referenced by GetCPInfo(), GetCPInfoExW(), IsDBCSLeadByteEx(), MultiByteToWideChar(), and WideCharToMultiByte().

◆ get_default_sublang()

static LANGID get_default_sublang ( LANGID  lang)
static

Definition at line 366 of file locale.c.

367{
368 switch (lang)
369 {
379 }
381 return lang;
382}
return
Definition: dirsup.c:529
#define MAKELANGID(p, s)
Definition: nls.h:15
#define SUBLANG_CHINESE_SINGAPORE
Definition: nls.h:211
#define LANG_SPANISH
Definition: nls.h:123
#define SUBLANG_CHINESE_MACAU
Definition: nls.h:212
#define SUBLANG_CHINESE_TRADITIONAL
Definition: nls.h:208
#define SUBLANG_CHINESE_SIMPLIFIED
Definition: nls.h:209
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define SUBLANG_CHINESE_HONGKONG
Definition: nls.h:210
#define LANG_CHINESE
Definition: nls.h:42
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define SUBLANG_SPANISH_MODERN
Definition: nls.h:338

Referenced by ConvertDefaultLocale(), GetLocaleInfoW(), and NLS_GetLanguageGroupName().

◆ get_dummy_preferred_ui_language()

static BOOL get_dummy_preferred_ui_language ( DWORD  flags,
ULONG count,
WCHAR buffer,
ULONG size 
)
static

Definition at line 1246 of file locale.c.

1247{
1248 LCTYPE type;
1249 int lsize;
1250
1251 FIXME("(0x%x %p %p %p) returning a dummy value (current locale)\n", flags, count, buffer, size);
1252
1253 if (flags & MUI_LANGUAGE_ID)
1255 else
1257
1259 if (!lsize)
1260 {
1261 /* keep last error from callee */
1262 return FALSE;
1263 }
1264 lsize++;
1265 if (!*size)
1266 {
1267 *size = lsize;
1268 *count = 1;
1269 return TRUE;
1270 }
1271
1272 if (lsize > *size)
1273 {
1275 return FALSE;
1276 }
1277
1279 {
1280 /* keep last error from callee */
1281 return FALSE;
1282 }
1283
1284 buffer[lsize-1] = 0;
1285 *size = lsize;
1286 *count = 1;
1287 TRACE("returned variable content: %d, \"%s\", %d\n", *count, debugstr_w(buffer), *size);
1288 return TRUE;
1289
1290}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
#define debugstr_w
Definition: kernel32.h:32
DWORD LCTYPE
Definition: winnls.h:517

Referenced by GetSystemPreferredUILanguages(), and GetThreadPreferredUILanguages().

◆ get_geoinfo_dataptr()

static const struct geoinfo_t * get_geoinfo_dataptr ( GEOID  geoid)
static

Definition at line 5463 of file locale.c.

5464{
5465 int min, max;
5466
5467 min = 0;
5468 max = sizeof(geoinfodata)/sizeof(struct geoinfo_t)-1;
5469
5470 while (min <= max) {
5471 const struct geoinfo_t *ptr;
5472 int n = (min+max)/2;
5473
5474 ptr = &geoinfodata[n];
5475 if (geoid == ptr->id)
5476 /* we don't need empty entries */
5477 return *ptr->iso2W ? ptr : NULL;
5478
5479 if (ptr->id > geoid)
5480 max = n-1;
5481 else
5482 min = n+1;
5483 }
5484
5485 return NULL;
5486}
GLdouble n
Definition: glext.h:7729
#define min(a, b)
Definition: monoChain.cc:55
#define max(a, b)
Definition: svc.c:63

Referenced by GetGeoInfoW().

◆ get_lcid_codepage()

static UINT get_lcid_codepage ( LCID  lcid)
inlinestatic

Definition at line 287 of file locale.c.

288{
289 UINT ret;
290 if (!GetLocaleInfoW( lcid, LOCALE_IDEFAULTANSICODEPAGE|LOCALE_RETURN_NUMBER, (WCHAR *)&ret,
291 sizeof(ret)/sizeof(WCHAR) )) ret = 0;
292 return ret;
293}

Referenced by CompareStringA(), get_codepage_table(), GetLocaleInfoA(), GetStringTypeA(), LCMapStringA(), LOCALE_Init(), and SetLocaleInfoA().

◆ get_locale()

static const char * get_locale ( int  category,
const char category_name 
)
static

Definition at line 1020 of file locale.c.

1021{
1022 const char* ret = setlocale(category, NULL);
1023
1024#ifdef __ANDROID__
1025 if (!strcmp(ret, "C"))
1026 {
1027 ret = getenv( category_name );
1028 if (!ret || !ret[0]) ret = getenv( "LC_ALL" );
1029 if (!ret || !ret[0]) ret = "C";
1030 }
1031#endif
1032
1033#ifdef __APPLE__
1034 /* If LC_ALL is set, respect it as a user override.
1035 If LC_* is set, respect it as a user override, except if it's LC_CTYPE
1036 and equal to UTF-8. That's because, when the Mac locale isn't supported
1037 by the C library, Terminal.app sets LC_CTYPE=UTF-8 and doesn't set LANG.
1038 parse_locale_name() doesn't handle that properly, so we override that
1039 with the Mac locale (which uses UTF-8 for the charset, anyway).
1040 Otherwise:
1041 For LC_MESSAGES, we override the C library because the user language
1042 setting is separate from the locale setting on which LANG was based.
1043 If the C library didn't get anything better from LANG than C or POSIX,
1044 override that. That probably means the Mac locale isn't supported by
1045 the C library. */
1046 if (!has_env( "LC_ALL" ) &&
1047 ((category == LC_CTYPE && !strcmp( ret, "UTF-8" )) ||
1048 (!has_env( category_name ) &&
1049 (category == LC_MESSAGES || !strcmp( ret, "C" ) || !strcmp( ret, "POSIX" )))))
1050 {
1051 const char* override = get_mac_locale();
1052
1053 if (category == LC_MESSAGES)
1054 {
1055 /* Retrieve the preferred language as chosen in System Preferences. */
1056 static char messages_locale[50];
1057
1058 if (!messages_locale[0])
1059 {
1060 CFArrayRef preferred_langs = CFLocaleCopyPreferredLanguages();
1061 if (preferred_langs && CFArrayGetCount( preferred_langs ))
1062 {
1063 CFStringRef preferred_lang = CFArrayGetValueAtIndex( preferred_langs, 0 );
1064 CFDictionaryRef components = CFLocaleCreateComponentsFromLocaleIdentifier( NULL, preferred_lang );
1065 if (components)
1066 {
1067 CFStringRef lang = CFDictionaryGetValue( components, kCFLocaleLanguageCode );
1068 CFStringRef country = CFDictionaryGetValue( components, kCFLocaleCountryCode );
1069 CFLocaleRef locale = NULL;
1070 CFStringRef locale_string;
1071
1072 if (!country)
1073 {
1074 locale = CFLocaleCopyCurrent();
1075 country = CFLocaleGetValue( locale, kCFLocaleCountryCode );
1076 }
1077
1078 if (country)
1079 locale_string = CFStringCreateWithFormat( NULL, NULL, CFSTR("%@_%@"), lang, country );
1080 else
1081 locale_string = CFStringCreateCopy( NULL, lang );
1082 CFStringGetCString( locale_string, messages_locale, sizeof(messages_locale), kCFStringEncodingUTF8 );
1083 strcat( messages_locale, ".UTF-8" );
1084
1085 CFRelease( locale_string );
1086 if (locale) CFRelease( locale );
1087 CFRelease( components );
1088 }
1089 }
1090 if (preferred_langs)
1091 CFRelease( preferred_langs );
1092 }
1093
1094 if (messages_locale[0])
1095 override = messages_locale;
1096 }
1097
1098 TRACE( "%s is %s; overriding with %s\n", category_name, debugstr_a(ret), debugstr_a(override) );
1099 ret = override;
1100 }
1101#endif
1102
1103 return ret;
1104}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
GLenum GLenum GLuint components
Definition: glext.h:9620
#define LC_CTYPE
Definition: locale.h:19
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
#define setlocale(n, s)
Definition: locale.h:46

◆ get_locale_registry_value()

static struct registry_value * get_locale_registry_value ( DWORD  lctype)
static

Definition at line 1451 of file locale.c.

1452{
1453 int i;
1454 for (i=0; i < sizeof(registry_values)/sizeof(registry_values[0]); i++)
1455 if (registry_values[i].lctype == lctype)
1456 return &registry_values[i];
1457 return NULL;
1458}
static struct registry_value registry_values[]

Referenced by GetLocaleInfoW(), and SetLocaleInfoW().

◆ get_registry_locale_info()

static INT get_registry_locale_info ( struct registry_value registry_value,
LPWSTR  buffer,
INT  len 
)
static

Definition at line 1467 of file locale.c.

1468{
1469 DWORD size;
1470 INT ret;
1471 HANDLE hkey;
1475 static const int info_size = FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data);
1476
1478
1480 {
1481 if (!(hkey = create_registry_key()))
1482 {
1484 return -1;
1485 }
1486
1488 size = info_size + len * sizeof(WCHAR);
1489
1490 if (!(info = HeapAlloc( GetProcessHeap(), 0, size )))
1491 {
1492 NtClose( hkey );
1495 return 0;
1496 }
1497
1499
1500 /* try again with a bigger buffer when we have to return the correct size */
1501 if (status == STATUS_BUFFER_OVERFLOW && !buffer && size > info_size)
1502 {
1504 if ((new_info = HeapReAlloc( GetProcessHeap(), 0, info, size )))
1505 {
1506 info = new_info;
1508 }
1509 }
1510
1511 NtClose( hkey );
1512
1513 if (!status)
1514 {
1515 INT length = (size - info_size) / sizeof(WCHAR);
1516 LPWSTR cached_value;
1517
1518 if (!length || ((WCHAR *)&info->Data)[length-1])
1519 length++;
1520
1521 cached_value = HeapAlloc( GetProcessHeap(), 0, length * sizeof(WCHAR) );
1522
1523 if (!cached_value)
1524 {
1525 HeapFree( GetProcessHeap(), 0, info );
1528 return 0;
1529 }
1530
1531 memcpy( cached_value, info->Data, (length-1) * sizeof(WCHAR) );
1532 cached_value[length-1] = 0;
1533 HeapFree( GetProcessHeap(), 0, info );
1534 registry_value->cached_value = cached_value;
1535 }
1536 else
1537 {
1539 {
1540 ret = (size - info_size) / sizeof(WCHAR);
1541 }
1543 {
1544 ret = -1;
1545 }
1546 else
1547 {
1549 ret = 0;
1550 }
1551 HeapFree( GetProcessHeap(), 0, info );
1553 return ret;
1554 }
1555 }
1556
1558
1559 if (buffer)
1560 {
1561 if (ret > len)
1562 {
1564 ret = 0;
1565 }
1566 else
1567 {
1569 }
1570 }
1571
1573
1574 return ret;
1575}
LONG NTSTATUS
Definition: precomp.h:26
#define HeapReAlloc
Definition: compat.h:734
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
static RTL_CRITICAL_SECTION cache_section
Definition: locale.c:262
static HANDLE create_registry_key(void)
Definition: locale.c:765
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLenum GLsizei len
Definition: glext.h:6722
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
@ KeyValuePartialInformation
Definition: nt_native.h:1182
NTSYSAPI NTSTATUS NTAPI NtQueryValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
WCHAR * cached_value
Definition: locale.c:214
const WCHAR * name
Definition: locale.c:213
Definition: ps.c:97
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149

Referenced by GetLocaleInfoW().

◆ get_table_entry()

static unsigned short get_table_entry ( const unsigned short table,
WCHAR  ch 
)
inlinestatic

Definition at line 276 of file locale.c.

277{
278 return table[table[table[ch >> 8] + ((ch >> 4) & 0x0f)] + (ch & 0xf)];
279}

Referenced by IdnToNameprepUnicode(), and IdnToUnicode().

◆ get_value_base_by_lctype()

static int get_value_base_by_lctype ( LCTYPE  lctype)
static

Definition at line 1655 of file locale.c.

1656{
1657 return lctype == LOCALE_ILANGUAGE || lctype == LOCALE_IDEFAULTLANGUAGE ? 16 : 10;
1658}
#define LOCALE_IDEFAULTLANGUAGE
Definition: winnls.h:35

Referenced by GetLocaleInfoW().

◆ GetACP()

◆ GetCPInfo()

BOOL WINAPI GetCPInfo ( UINT  codepage,
LPCPINFO  cpinfo 
)

Definition at line 2143 of file locale.c.

2144{
2145 const union cptable *table;
2146
2147 if (!cpinfo)
2148 {
2150 return FALSE;
2151 }
2152
2153 if (!(table = get_codepage_table( codepage )))
2154 {
2155 switch(codepage)
2156 {
2157 case CP_UTF7:
2158 case CP_UTF8:
2159 cpinfo->DefaultChar[0] = 0x3f;
2160 cpinfo->DefaultChar[1] = 0;
2161 cpinfo->LeadByte[0] = cpinfo->LeadByte[1] = 0;
2162 cpinfo->MaxCharSize = (codepage == CP_UTF7) ? 5 : 4;
2163 return TRUE;
2164 }
2165
2167 return FALSE;
2168 }
2169 if (table->info.def_char & 0xff00)
2170 {
2171 cpinfo->DefaultChar[0] = (table->info.def_char & 0xff00) >> 8;
2172 cpinfo->DefaultChar[1] = table->info.def_char & 0x00ff;
2173 }
2174 else
2175 {
2176 cpinfo->DefaultChar[0] = table->info.def_char & 0xff;
2177 cpinfo->DefaultChar[1] = 0;
2178 }
2179 if ((cpinfo->MaxCharSize = table->info.char_size) == 2)
2180 memcpy( cpinfo->LeadByte, table->dbcs.lead_bytes, sizeof(cpinfo->LeadByte) );
2181 else
2182 cpinfo->LeadByte[0] = cpinfo->LeadByte[1] = 0;
2183
2184 return TRUE;
2185}
static const union cptable * get_codepage_table(unsigned int codepage)
Definition: locale.c:301
BYTE LeadByte[MAX_LEADBYTES]
Definition: winnls.h:583
BYTE DefaultChar[MAX_DEFAULTCHAR]
Definition: winnls.h:582
UINT MaxCharSize
Definition: winnls.h:581

Referenced by _Locale_codecvt_create(), _Locale_ctype_create(), _setmbcp_l(), GetCPInfoExW(), GetKerningPairsA(), Global_Chr(), make_csconv(), ME_GetTextLengthEx(), MSVCRT__create_locale(), test_GetCPInfo(), and test_mbcp().

◆ GetCPInfoExA()

BOOL WINAPI GetCPInfoExA ( UINT  codepage,
DWORD  dwFlags,
LPCPINFOEXA  cpinfo 
)

Definition at line 2201 of file locale.c.

2202{
2203 CPINFOEXW cpinfoW;
2204
2205 if (!GetCPInfoExW( codepage, dwFlags, &cpinfoW ))
2206 return FALSE;
2207
2208 /* the layout is the same except for CodePageName */
2209 memcpy(cpinfo, &cpinfoW, sizeof(CPINFOEXA));
2210 WideCharToMultiByte(CP_ACP, 0, cpinfoW.CodePageName, -1, cpinfo->CodePageName, sizeof(cpinfo->CodePageName), NULL, NULL);
2211 return TRUE;
2212}
BOOL WINAPI GetCPInfoExW(UINT codepage, DWORD dwFlags, LPCPINFOEXW cpinfo)
Definition: locale.c:2219
CHAR CodePageName[MAX_PATH]
Definition: winnls.h:591
WCHAR CodePageName[MAX_PATH]
Definition: winnls.h:599

Referenced by init_procs(), and test_threadcp().

◆ GetCPInfoExW()

BOOL WINAPI GetCPInfoExW ( UINT  codepage,
DWORD  dwFlags,
LPCPINFOEXW  cpinfo 
)

Definition at line 2219 of file locale.c.

2220{
2221 if (!GetCPInfo( codepage, (LPCPINFO)cpinfo ))
2222 return FALSE;
2223
2224 switch(codepage)
2225 {
2226 case CP_UTF7:
2227 {
2228 static const WCHAR utf7[] = {'U','n','i','c','o','d','e',' ','(','U','T','F','-','7',')',0};
2229
2230 cpinfo->CodePage = CP_UTF7;
2231 cpinfo->UnicodeDefaultChar = 0x3f;
2232 strcpyW(cpinfo->CodePageName, utf7);
2233 break;
2234 }
2235
2236 case CP_UTF8:
2237 {
2238 static const WCHAR utf8[] = {'U','n','i','c','o','d','e',' ','(','U','T','F','-','8',')',0};
2239
2240 cpinfo->CodePage = CP_UTF8;
2241 cpinfo->UnicodeDefaultChar = 0x3f;
2242 strcpyW(cpinfo->CodePageName, utf8);
2243 break;
2244 }
2245
2246 default:
2247 {
2248 const union cptable *table = get_codepage_table( codepage );
2249
2250 cpinfo->CodePage = table->info.codepage;
2251 cpinfo->UnicodeDefaultChar = table->info.def_unicode_char;
2252 MultiByteToWideChar( CP_ACP, 0, table->info.name, -1, cpinfo->CodePageName,
2253 sizeof(cpinfo->CodePageName)/sizeof(WCHAR));
2254 break;
2255 }
2256 }
2257 return TRUE;
2258}
BOOL WINAPI GetCPInfo(UINT codepage, LPCPINFO cpinfo)
Definition: locale.c:2143
#define strcpyW(d, s)
Definition: unicode.h:35
const WCHAR * name

Referenced by AddCodePage(), FillCharacterSetComboList(), GetCPInfoExA(), GetSupportedCP(), and ME_StreamOutRTFHeader().

◆ GetFileMUIInfo()

BOOL WINAPI GetFileMUIInfo ( DWORD  flags,
PCWSTR  path,
FILEMUIINFO info,
DWORD size 
)

Definition at line 6227 of file locale.c.

6228{
6229 FIXME("stub: %u, %s, %p, %p\n", flags, debugstr_w(path), info, size);
6230
6232 return FALSE;
6233}
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102

◆ GetFileMUIPath()

BOOL WINAPI GetFileMUIPath ( DWORD  flags,
PCWSTR  filepath,
PWSTR  language,
PULONG  languagelen,
PWSTR  muipath,
PULONG  muipathlen,
PULONGLONG  enumerator 
)

Definition at line 6212 of file locale.c.

6214{
6215 FIXME("stub: 0x%x, %s, %s, %p, %p, %p, %p\n", flags, debugstr_w(filepath),
6216 debugstr_w(language), languagelen, muipath, muipathlen, enumerator);
6217
6219
6220 return FALSE;
6221}

◆ GetGeoInfoA()

INT WINAPI GetGeoInfoA ( GEOID  geoid,
GEOTYPE  geotype,
LPSTR  data,
int  data_len,
LANGID  lang 
)

Definition at line 5565 of file locale.c.

5566{
5567 WCHAR *buffW;
5568 INT len;
5569
5570 TRACE("%d %d %p %d %d\n", geoid, geotype, data, data_len, lang);
5571
5572 len = GetGeoInfoW(geoid, geotype, NULL, 0, lang);
5573 if (!len)
5574 return 0;
5575
5576 buffW = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
5577 if (!buffW)
5578 return 0;
5579
5580 GetGeoInfoW(geoid, geotype, buffW, len, lang);
5581 len = WideCharToMultiByte(CP_ACP, 0, buffW, -1, NULL, 0, NULL, NULL);
5582 if (!data || !data_len) {
5583 HeapFree(GetProcessHeap(), 0, buffW);
5584 return len;
5585 }
5586
5587 len = WideCharToMultiByte(CP_ACP, 0, buffW, -1, data, data_len, NULL, NULL);
5588 HeapFree(GetProcessHeap(), 0, buffW);
5589
5590 if (data_len < len)
5592 return data_len < len ? 0 : len;
5593}
INT WINAPI GetGeoInfoW(GEOID geoid, GEOTYPE geotype, LPWSTR data, int data_len, LANGID lang)
Definition: locale.c:5491

Referenced by InitFunctionPointers().

◆ GetGeoInfoW()

INT WINAPI GetGeoInfoW ( GEOID  geoid,
GEOTYPE  geotype,
LPWSTR  data,
int  data_len,
LANGID  lang 
)

Definition at line 5491 of file locale.c.

5492{
5493 const struct geoinfo_t *ptr;
5494 const WCHAR *str = NULL;
5495 WCHAR buffW[12];
5496 LONG val = 0;
5497 INT len;
5498
5499 TRACE("%d %d %p %d %d\n", geoid, geotype, data, data_len, lang);
5500
5501 if (!(ptr = get_geoinfo_dataptr(geoid))) {
5503 return 0;
5504 }
5505
5506 switch (geotype) {
5507 case GEO_FRIENDLYNAME:
5508 {
5509#ifdef __REACTOS__
5510 return NLS_GetGeoFriendlyName(geoid, data, data_len, lang);
5511#else
5512 return NLS_GetGeoFriendlyName(geoid, data, data_len);
5513#endif
5514 }
5515 case GEO_NATION:
5516 val = geoid;
5517 break;
5518 case GEO_ISO_UN_NUMBER:
5519 val = ptr->uncode;
5520 break;
5521 case GEO_PARENT:
5522 val = ptr->parent;
5523 break;
5524 case GEO_ISO2:
5525 case GEO_ISO3:
5526 {
5527 str = geotype == GEO_ISO2 ? ptr->iso2W : ptr->iso3W;
5528 break;
5529 }
5530 case GEO_RFC1766:
5531 case GEO_LCID:
5532 case GEO_OFFICIALNAME:
5533 case GEO_TIMEZONES:
5535 case GEO_LATITUDE:
5536 case GEO_LONGITUDE:
5537 FIXME("type %d is not supported\n", geotype);
5539 return 0;
5540 default:
5541 WARN("unrecognized type %d\n", geotype);
5543 return 0;
5544 }
5545
5546 if (val) {
5547 static const WCHAR fmtW[] = {'%','d',0};
5548 sprintfW(buffW, fmtW, val);
5549 str = buffW;
5550 }
5551
5552 len = strlenW(str) + 1;
5553 if (!data || !data_len)
5554 return len;
5555
5556 memcpy(data, str, min(len, data_len)*sizeof(WCHAR));
5557 if (data_len < len)
5559 return data_len < len ? 0 : len;
5560}
#define WARN(fmt,...)
Definition: precomp.h:61
static const struct geoinfo_t * get_geoinfo_dataptr(GEOID geoid)
Definition: locale.c:5463
GLuint GLfloat * val
Definition: glext.h:7180
long LONG
Definition: pedump.c:60
const WCHAR * str
@ GEO_ISO3
Definition: winnls.h:566
@ GEO_OFFICIALLANGUAGES
Definition: winnls.h:572
@ GEO_OFFICIALNAME
Definition: winnls.h:570
@ GEO_TIMEZONES
Definition: winnls.h:571
@ GEO_FRIENDLYNAME
Definition: winnls.h:569
@ GEO_LONGITUDE
Definition: winnls.h:564
@ GEO_ISO_UN_NUMBER
Definition: winnls.h:573
@ GEO_PARENT
Definition: winnls.h:574
@ GEO_ISO2
Definition: winnls.h:565
@ GEO_LATITUDE
Definition: winnls.h:563
@ GEO_NATION
Definition: winnls.h:562
@ GEO_LCID
Definition: winnls.h:568
@ GEO_RFC1766
Definition: winnls.h:567

Referenced by CreateLocationsList(), GetGeoInfoA(), InitFunctionPointers(), LocationsEnumProc(), and SetUserLocaleName().

◆ GetLocaleInfoA()

INT WINAPI GetLocaleInfoA ( LCID  lcid,
LCTYPE  lctype,
LPSTR  buffer,
INT  len 
)

Definition at line 1599 of file locale.c.

1600{
1601 WCHAR *bufferW;
1602 INT lenW, ret;
1603
1604 TRACE( "(lcid=0x%x,lctype=0x%x,%p,%d)\n", lcid, lctype, buffer, len );
1605
1606 if (len < 0 || (len && !buffer))
1607 {
1609 return 0;
1610 }
1611 if (((lctype & ~LOCALE_LOCALEINFOFLAGSMASK) == LOCALE_SSHORTTIME) ||
1613 {
1615 return 0;
1616 }
1617
1618 if (!len) buffer = NULL;
1619
1620 if (!(lenW = GetLocaleInfoW( lcid, lctype, NULL, 0 ))) return 0;
1621
1622 if (!(bufferW = HeapAlloc( GetProcessHeap(), 0, lenW * sizeof(WCHAR) )))
1623 {
1625 return 0;
1626 }
1627 if ((ret = GetLocaleInfoW( lcid, lctype, bufferW, lenW )))
1628 {
1629 if ((lctype & LOCALE_RETURN_NUMBER) ||
1631 {
1632 /* it's not an ASCII string, just bytes */
1633 ret *= sizeof(WCHAR);
1634 if (buffer)
1635 {
1636 if (ret <= len) memcpy( buffer, bufferW, ret );
1637 else
1638 {
1640 ret = 0;
1641 }
1642 }
1643 }
1644 else
1645 {
1647 if (!(lctype & LOCALE_USE_CP_ACP)) codepage = get_lcid_codepage( lcid );
1648 ret = WideCharToMultiByte( codepage, 0, bufferW, ret, buffer, len, NULL, NULL );
1649 }
1650 }
1651 HeapFree( GetProcessHeap(), 0, bufferW );
1652 return ret;
1653}
#define LOCALE_LOCALEINFOFLAGSMASK
Definition: locale.c:57
#define LOCALE_SSHORTTIME
Definition: winnls.h:163

Referenced by __GetLocaleInfoUsingACP(), __GetLocaleName(), __intGetACP(), __intGetOCP(), _Locale_monetary_create(), _Locale_n_cs_precedes(), _Locale_n_sep_by_space(), _Locale_n_sign_posn(), _Locale_numeric_create(), _Locale_p_cs_precedes(), _Locale_p_sep_by_space(), _Locale_p_sign_posn(), _Locale_time_create(), compare_info(), detect_locale(), DosGetCountryInfo(), EnumLocalesProcA(), filetime_to_str(), is_rtl(), lcid_to_rfc1766A(), lineGetTranslateCapsA(), MSVCRT__create_locale(), MSVCRT_locale_to_LCID(), NLS_EnumDateFormats(), NLS_EnumTimeFormats(), START_TEST(), test__Gettnames(), test_EM_POSFROMCHAR(), test_EM_SETCHARFORMAT(), test_EnumDateFormatsA(), test_EnumTimeFormatsA(), test_EnumTimeFormatsW(), test_firstDay(), test_GetAcceptLanguagesA(), test_GetLocaleInfoA(), test_GetLocaleInfoW(), test_hittest(), test_invariant(), test_setlocale(), test_threadcp(), test_VarAbs(), test_VarCat(), test_VarFormat(), test_VarFormatNumber(), test_VarRound(), test_wm_set_get_text(), update_threadlocinfo_category(), and VerLanguageNameA().

◆ GetLocaleInfoW()

INT WINAPI GetLocaleInfoW ( LCID  lcid,
LCTYPE  lctype,
LPWSTR  buffer,
INT  len 
)

Definition at line 1665 of file locale.c.

1666{
1667 LANGID lang_id;
1668 HRSRC hrsrc;
1669 HGLOBAL hmem;
1670 INT ret;
1671 UINT lcflags;
1672 const WCHAR *p;
1673 unsigned int i;
1674
1675 if (len < 0 || (len && !buffer))
1676 {
1678 return 0;
1679 }
1680 if (lctype & LOCALE_RETURN_GENITIVE_NAMES &&
1681 !is_genitive_name_supported( lctype ))
1682 {
1684 return 0;
1685 }
1686
1687 if (!len) buffer = NULL;
1688
1689 lcid = convert_default_lcid( lcid, lctype );
1690
1691 lcflags = lctype & LOCALE_LOCALEINFOFLAGSMASK;
1692 lctype &= 0xffff;
1693
1694 TRACE( "(lcid=0x%x,lctype=0x%x,%p,%d)\n", lcid, lctype, buffer, len );
1695
1696 /* first check for overrides in the registry */
1697
1698 if (!(lcflags & LOCALE_NOUSEROVERRIDE) &&
1699 lcid == convert_default_lcid( LOCALE_USER_DEFAULT, lctype ))
1700 {
1702
1703 if (value)
1704 {
1705 if (lcflags & LOCALE_RETURN_NUMBER)
1706 {
1707 WCHAR tmp[16];
1708 ret = get_registry_locale_info( value, tmp, sizeof(tmp)/sizeof(WCHAR) );
1709 if (ret > 0)
1710 {
1711 WCHAR *end;
1713 if (*end) /* invalid number */
1714 {
1716 return 0;
1717 }
1718 ret = sizeof(UINT)/sizeof(WCHAR);
1719 if (!buffer) return ret;
1720 if (ret > len)
1721 {
1723 return 0;
1724 }
1725 memcpy( buffer, &number, sizeof(number) );
1726 }
1727 }
1729
1730 if (ret != -1) return ret;
1731 }
1732 }
1733
1734 /* now load it from kernel resources */
1735
1736 lang_id = LANGIDFROMLCID( lcid );
1737
1738 /* replace SUBLANG_NEUTRAL by SUBLANG_DEFAULT */
1739 if (SUBLANGID(lang_id) == SUBLANG_NEUTRAL) lang_id = get_default_sublang( lang_id );
1740
1742 ULongToPtr((lctype >> 4) + 1), lang_id )))
1743 {
1744 SetLastError( ERROR_INVALID_FLAGS ); /* no such lctype */
1745 return 0;
1746 }
1747 if (!(hmem = LoadResource( kernel32_handle, hrsrc )))
1748 return 0;
1749
1750 p = LockResource( hmem );
1751 for (i = 0; i < (lctype & 0x0f); i++) p += *p + 1;
1752
1753 if (lcflags & LOCALE_RETURN_NUMBER) ret = sizeof(UINT)/sizeof(WCHAR);
1754 else if (is_genitive_name_supported( lctype ) && *p)
1755 {
1756 /* genitive form's stored after a null separator from a nominative */
1757 for (i = 1; i <= *p; i++) if (!p[i]) break;
1758
1759 if (i <= *p && (lcflags & LOCALE_RETURN_GENITIVE_NAMES))
1760 {
1761 ret = *p - i + 1;
1762 p += i;
1763 }
1764 else ret = i;
1765 }
1766 else
1767 ret = (lctype == LOCALE_FONTSIGNATURE) ? *p : *p + 1;
1768
1769 if (!buffer) return ret;
1770
1771 if (ret > len)
1772 {
1774 return 0;
1775 }
1776
1777 if (lcflags & LOCALE_RETURN_NUMBER)
1778 {
1779 UINT number;
1780 WCHAR *end, *tmp = HeapAlloc( GetProcessHeap(), 0, (*p + 1) * sizeof(WCHAR) );
1781 if (!tmp) return 0;
1782 memcpy( tmp, p + 1, *p * sizeof(WCHAR) );
1783 tmp[*p] = 0;
1785 if (!*end)
1786 memcpy( buffer, &number, sizeof(number) );
1787 else /* invalid number */
1788 {
1790 ret = 0;
1791 }
1792 HeapFree( GetProcessHeap(), 0, tmp );
1793
1794 TRACE( "(lcid=0x%x,lctype=0x%x,%p,%d) returning number %d\n",
1795 lcid, lctype, buffer, len, number );
1796 }
1797 else
1798 {
1799 memcpy( buffer, p + 1, ret * sizeof(WCHAR) );
1800 if (lctype != LOCALE_FONTSIGNATURE) buffer[ret-1] = 0;
1801
1802 TRACE( "(lcid=0x%x,lctype=0x%x,%p,%d) returning %d %s\n",
1803 lcid, lctype, buffer, len, ret, debugstr_w(buffer) );
1804 }
1805 return ret;
1806}
#define ULongToPtr(ul)
Definition: basetsd.h:92
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HRSRC WINAPI FindResourceExW(HMODULE hModule, LPCWSTR type, LPCWSTR name, WORD lang)
Definition: res.c:164
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
static struct registry_value * get_locale_registry_value(DWORD lctype)
Definition: locale.c:1451
static INT get_registry_locale_info(struct registry_value *registry_value, LPWSTR buffer, INT len)
Definition: locale.c:1467
static LCID convert_default_lcid(LCID lcid, LCTYPE lctype)
Definition: locale.c:586
static BOOL is_genitive_name_supported(LCTYPE lctype)
Definition: locale.c:737
static int get_value_base_by_lctype(LCTYPE lctype)
Definition: locale.c:1655
GLuint GLuint end
Definition: gl.h:1545
static unsigned int number
Definition: dsound.c:1479
#define strtolW(s, e, b)
Definition: unicode.h:39
DWORD lctype
Definition: locale.c:212
Definition: pdh_main.c:94

Referenced by __crtGetLocaleInfoW(), _WLocale_abbrev_dayofweek(), _WLocale_abbrev_monthname(), _WLocale_am_str(), _WLocale_currency_symbol(), _WLocale_decimal_point(), _WLocale_full_dayofweek(), _WLocale_full_monthname(), _WLocale_int_curr_symbol(), _WLocale_negative_sign(), _WLocale_pm_str(), _WLocale_positive_sign(), _WLocale_thousands_sep(), AboutDlgProc(), add_cert_to_list(), add_cert_to_view(), add_date_string_to_control(), AddCommasW(), AddNewKbLayoutsByLcid(), AddNewLayout(), AllSysInfo(), CConfigParser::CacheINI(), create_utc_string(), CreateLanguagesList(), CreateLayoutIcon(), CreateSortList(), date_parse(), date_to_string(), dateobj_to_date_string(), DATETIME_GetFieldWidth(), DATETIME_ReturnTxt(), DATETIME_SetFormatW(), detect_locale(), enum_locale_ex_proc(), enum_locales_proc(), fill_language_information(), FillMonthsComboBox(), FillNumberFmt(), fnIMultiLanguage3_GetRfc1766Info(), fnIMultiLanguage_GetRfc1766Info(), format_long_date(), format_size(), FormatInteger(), GeneralPropertyPageLocalesEnumProc(), get_countrycode(), get_date_format(), get_decimal_sep(), get_dummy_preferred_ui_language(), get_input_codepage(), get_lcid_codepage(), get_locale(), GetCalendarInfoW(), CicProfile::GetCodePageA(), GetCurrencyFormatW(), GetFileVersion(), GetFontSig(), GetHKLName(), GetKeyboardLayoutCP(), GetLocaleInfoA(), GetLocalizedSMFolderName(), GetNumberFormatW(), CConfigParser::GetSectionString(), InatCreateIconBySize(), InitializeDefaultUserLocale(), InitLanguagesList(), InputList_Add(), InputList_Create(), Int64GetNumFormat(), IntGetCodePageEntry(), is_default_metric(), IsBiDiLocalizedSystem(), IsLayoutExists(), lcid_to_rfc1766W(), LOCALE_Init(), LOCALE_InitRegistry(), locale_update_registry(), LocaleList_Create(), LocalesEnumProc(), MONTHCAL_LButtonDown(), MONTHCAL_PaintTitle(), MONTHCAL_SetFirstDayOfWeek(), MonthCalFirstDayOfWeek(), MonthCalReload(), MSVCRT__create_locale(), NLS_EnumCalendarInfo(), NLS_EnumDateFormats(), NLS_EnumTimeFormats(), NLS_GetLocaleNumber(), NLS_GetLocaleString(), ParseDate(), ReadChmSystem(), SaveFontSubstitutionSettings(), SaveSystemSettings(), ScriptRecordDigitSubstitution(), SetUserLocaleName(), SH_FormatInteger(), SortEnumProc(), START_TEST(), test_EnumTimeFormatsW(), test_GetLocaleInfoEx(), test_GetLocaleInfoW(), test_unicode_wm_char(), test_VarWeekdayName(), TranslateCharsetInfo(), UPDOWN_GetThousandSep(), VarBstrFromDate(), VarDateFromStr(), VarFormatCurrency(), VarFormatNumber(), VARIANT_BstrReplaceDecimal(), VARIANT_FormatDate(), VARIANT_FormatNumber(), VARIANT_GetLocalisedNumberChars(), VarMonthName(), VarWeekdayName(), VerLanguageNameW(), and WriteUserLocale().

◆ GetLocalisedText()

UINT GetLocalisedText ( IN UINT  uID,
IN LPWSTR  lpszDest,
IN UINT  cchDest 
)

◆ GetOEMCP()

◆ GetStringTypeA()

BOOL WINAPI GetStringTypeA ( LCID  locale,
DWORD  type,
LPCSTR  src,
INT  count,
LPWORD  chartype 
)

Definition at line 3208 of file locale.c.

3209{
3210 UINT cp;
3211 INT countW;
3212 LPWSTR srcW;
3213 BOOL ret = FALSE;
3214
3215 if(count == -1) count = strlen(src) + 1;
3216
3217 if (!(cp = get_lcid_codepage( locale )))
3218 {
3219 FIXME("For locale %04x using current ANSI code page\n", locale);
3220 cp = GetACP();
3221 }
3222
3223 countW = MultiByteToWideChar(cp, 0, src, count, NULL, 0);
3224 if((srcW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR))))
3225 {
3226 MultiByteToWideChar(cp, 0, src, count, srcW, countW);
3227 /*
3228 * NOTE: the target buffer has 1 word for each CHARACTER in the source
3229 * string, with multibyte characters there maybe be more bytes in count
3230 * than character space in the buffer!
3231 */
3232 ret = GetStringTypeW(type, srcW, countW, chartype);
3233 HeapFree(GetProcessHeap(), 0, srcW);
3234 }
3235 return ret;
3236}
UINT WINAPI GetACP(void)
Definition: locale.c:2020
BOOL WINAPI GetStringTypeW(DWORD type, LPCWSTR src, INT count, LPWORD chartype)
Definition: locale.c:3094
unsigned int BOOL
Definition: ntddk_ex.h:94
POINT cp
Definition: magnifier.c:59

Referenced by _Locale_ctype_create(), GetStringTypeExA(), IsCharSpaceA(), and MSVCRT__create_locale().

◆ GetStringTypeExA()

BOOL WINAPI GetStringTypeExA ( LCID  locale,
DWORD  type,
LPCSTR  src,
INT  count,
LPWORD  chartype 
)

Definition at line 3255 of file locale.c.

3256{
3257 return GetStringTypeA(locale, type, src, count, chartype);
3258}
BOOL WINAPI GetStringTypeA(LCID locale, DWORD type, LPCSTR src, INT count, LPWORD chartype)
Definition: locale.c:3208

Referenced by _isctype_l().

◆ GetStringTypeExW()

BOOL WINAPI GetStringTypeExW ( LCID  locale,
DWORD  type,
LPCWSTR  src,
INT  count,
LPWORD  chartype 
)

Definition at line 3184 of file locale.c.

3185{
3186 /* locale is ignored for Unicode */
3187 return GetStringTypeW( type, src, count, chartype );
3188}

◆ GetStringTypeW()

BOOL WINAPI GetStringTypeW ( DWORD  type,
LPCWSTR  src,
INT  count,
LPWORD  chartype 
)

Definition at line 3094 of file locale.c.

3095{
3096 static const unsigned char type2_map[16] =
3097 {
3098 C2_NOTAPPLICABLE, /* unassigned */
3099 C2_LEFTTORIGHT, /* L */
3100 C2_RIGHTTOLEFT, /* R */
3101 C2_EUROPENUMBER, /* EN */
3102 C2_EUROPESEPARATOR, /* ES */
3103 C2_EUROPETERMINATOR, /* ET */
3104 C2_ARABICNUMBER, /* AN */
3105 C2_COMMONSEPARATOR, /* CS */
3106 C2_BLOCKSEPARATOR, /* B */
3107 C2_SEGMENTSEPARATOR, /* S */
3108 C2_WHITESPACE, /* WS */
3109 C2_OTHERNEUTRAL, /* ON */
3110 C2_RIGHTTOLEFT, /* AL */
3111 C2_NOTAPPLICABLE, /* NSM */
3112 C2_NOTAPPLICABLE, /* BN */
3113 C2_OTHERNEUTRAL /* LRE, LRO, RLE, RLO, PDF */
3114 };
3115
3116 if (!src)
3117 {
3119 return FALSE;
3120 }
3121
3122 if (count == -1) count = strlenW(src) + 1;
3123 switch(type)
3124 {
3125 case CT_CTYPE1:
3126 while (count--) *chartype++ = get_char_typeW( *src++ ) & 0xfff;
3127 break;
3128 case CT_CTYPE2:
3129 while (count--) *chartype++ = type2_map[get_char_typeW( *src++ ) >> 12];
3130 break;
3131 case CT_CTYPE3:
3132 {
3133 WARN("CT_CTYPE3: semi-stub.\n");
3134 while (count--)
3135 {
3136 int c = *src;
3137 WORD type1, type3 = 0; /* C3_NOTAPPLICABLE */
3138
3139 type1 = get_char_typeW( *src++ ) & 0xfff;
3140 /* try to construct type3 from type1 */
3141 if(type1 & C1_SPACE) type3 |= C3_SYMBOL;
3142 if(type1 & C1_ALPHA) type3 |= C3_ALPHA;
3143 if ((c>=0x30A0)&&(c<=0x30FF)) type3 |= C3_KATAKANA;
3144 if ((c>=0x3040)&&(c<=0x309F)) type3 |= C3_HIRAGANA;
3145 if ((c>=0x4E00)&&(c<=0x9FAF)) type3 |= C3_IDEOGRAPH;
3146 if (c == 0x0640) type3 |= C3_KASHIDA;
3147 if ((c>=0x3000)&&(c<=0x303F)) type3 |= C3_SYMBOL;
3148
3149 if ((c>=0xD800)&&(c<=0xDBFF)) type3 |= C3_HIGHSURROGATE;
3150 if ((c>=0xDC00)&&(c<=0xDFFF)) type3 |= C3_LOWSURROGATE;
3151
3152 if ((c>=0xFF00)&&(c<=0xFF60)) type3 |= C3_FULLWIDTH;
3153 if ((c>=0xFF00)&&(c<=0xFF20)) type3 |= C3_SYMBOL;
3154 if ((c>=0xFF3B)&&(c<=0xFF40)) type3 |= C3_SYMBOL;
3155 if ((c>=0xFF5B)&&(c<=0xFF60)) type3 |= C3_SYMBOL;
3156 if ((c>=0xFF21)&&(c<=0xFF3A)) type3 |= C3_ALPHA;
3157 if ((c>=0xFF41)&&(c<=0xFF5A)) type3 |= C3_ALPHA;
3158 if ((c>=0xFFE0)&&(c<=0xFFE6)) type3 |= C3_FULLWIDTH;
3159 if ((c>=0xFFE0)&&(c<=0xFFE6)) type3 |= C3_SYMBOL;
3160
3161 if ((c>=0xFF61)&&(c<=0xFFDC)) type3 |= C3_HALFWIDTH;
3162 if ((c>=0xFF61)&&(c<=0xFF64)) type3 |= C3_SYMBOL;
3163 if ((c>=0xFF65)&&(c<=0xFF9F)) type3 |= C3_KATAKANA;
3164 if ((c>=0xFF65)&&(c<=0xFF9F)) type3 |= C3_ALPHA;
3165 if ((c>=0xFFE8)&&(c<=0xFFEE)) type3 |= C3_HALFWIDTH;
3166 if ((c>=0xFFE8)&&(c<=0xFFEE)) type3 |= C3_SYMBOL;
3167 *chartype++ = type3;
3168 }
3169 break;
3170 }
3171 default:
3173 return FALSE;
3174 }
3175 return TRUE;
3176}
unsigned short WORD
Definition: ntddk_ex.h:93
const GLubyte * c
Definition: glext.h:8905
#define C1_SPACE
Definition: unicode.h:34
#define C1_ALPHA
Definition: unicode.h:39
WINE_UNICODE_INLINE unsigned short get_char_typeW(WCHAR ch)
Definition: unicode.h:149
#define C2_ARABICNUMBER
Definition: winnls.h:255
#define C3_FULLWIDTH
Definition: winnls.h:269
#define C3_ALPHA
Definition: winnls.h:273
#define C2_OTHERNEUTRAL
Definition: winnls.h:260
#define C2_LEFTTORIGHT
Definition: winnls.h:250
#define CT_CTYPE2
Definition: winnls.h:238
#define C3_IDEOGRAPH
Definition: winnls.h:270
#define CT_CTYPE3
Definition: winnls.h:239
#define CT_CTYPE1
Definition: winnls.h:237
#define C3_HALFWIDTH
Definition: winnls.h:268
#define C2_EUROPENUMBER
Definition: winnls.h:252
#define C3_SYMBOL
Definition: winnls.h:265
#define C3_LOWSURROGATE
Definition: winnls.h:276
#define C2_COMMONSEPARATOR
Definition: winnls.h:256
#define C3_KATAKANA
Definition: winnls.h:266
#define C2_EUROPESEPARATOR
Definition: winnls.h:253
#define C2_EUROPETERMINATOR
Definition: winnls.h:254
#define C2_SEGMENTSEPARATOR
Definition: winnls.h:258
#define C3_KASHIDA
Definition: winnls.h:271
#define C2_RIGHTTOLEFT
Definition: winnls.h:251
#define C3_HIRAGANA
Definition: winnls.h:267
#define C2_WHITESPACE
Definition: winnls.h:259
#define C3_HIGHSURROGATE
Definition: winnls.h:275
#define C2_NOTAPPLICABLE
Definition: winnls.h:261
#define C2_BLOCKSEPARATOR
Definition: winnls.h:257

Referenced by __crtGetStringTypeW(), _Locale_ctype_create(), _setmbcp_l(), _WLocale_ctype(), DoWordBreakProc(), get_char_script(), GetC1Type(), GetStringType3ExW(), GetStringTypeA(), GetStringTypeExW(), IsBlankLine(), IsCharBlankW(), IsCharCntrlW(), IsCharDigitW(), IsCharPunctW(), IsCharSpaceW(), IsCharXDigitW(), isdigitW(), SampCheckPassword(), test_crtGetStringTypeW(), and test_GetStringTypeW().

◆ GetSystemDefaultLangID()

◆ GetSystemDefaultLCID()

◆ GetSystemDefaultLocaleName()

INT WINAPI GetSystemDefaultLocaleName ( LPWSTR  localename,
INT  len 
)

Definition at line 1240 of file locale.c.

1241{
1242 LCID lcid = GetSystemDefaultLCID();
1243 return LCIDToLocaleName(lcid, localename, len, 0);
1244}

◆ GetSystemDefaultUILanguage()

LANGID WINAPI GetSystemDefaultUILanguage ( void  )

Definition at line 1394 of file locale.c.

1395{
1396 LANGID lang;
1398 return lang;
1399}
NTSTATUS NTAPI NtQueryInstallUILanguage(OUT LANGID *LanguageId)
Definition: locale.c:611

Referenced by LsaLookupPrivilegeDisplayName(), and SHGetWebFolderFilePathW().

◆ GetSystemPreferredUILanguages()

BOOL WINAPI GetSystemPreferredUILanguages ( DWORD  flags,
ULONG count,
WCHAR buffer,
ULONG size 
)

Definition at line 1295 of file locale.c.

1296{
1297 if (flags & ~(MUI_LANGUAGE_NAME | MUI_LANGUAGE_ID | MUI_MACHINE_LANGUAGE_SETTINGS))
1298 {
1300 return FALSE;
1301 }
1302 if ((flags & MUI_LANGUAGE_NAME) && (flags & MUI_LANGUAGE_ID))
1303 {
1305 return FALSE;
1306 }
1307 if (*size && !buffer)
1308 {
1310 return FALSE;
1311 }
1312
1314}
static BOOL get_dummy_preferred_ui_language(DWORD flags, ULONG *count, WCHAR *buffer, ULONG *size)
Definition: locale.c:1246

Referenced by InitFunctionPointers().

◆ GetThreadLocale()

◆ GetThreadPreferredUILanguages()

BOOL WINAPI GetThreadPreferredUILanguages ( DWORD  flags,
ULONG count,
WCHAR buf,
ULONG size 
)

Definition at line 1328 of file locale.c.

1329{
1330 FIXME( "%08x, %p, %p %p\n", flags, count, buf, size );
1332}

Referenced by InitFunctionPointers().

◆ GetUserDefaultLangID()

◆ GetUserDefaultLCID()

◆ GetUserDefaultLocaleName()

INT WINAPI GetUserDefaultLocaleName ( LPWSTR  localename,
int  buffersize 
)

Definition at line 5645 of file locale.c.

5646{
5647 LCID userlcid;
5648
5649 TRACE("%p, %d\n", localename, buffersize);
5650
5651 userlcid = GetUserDefaultLCID();
5652 return LCIDToLocaleName(userlcid, localename, buffersize, 0);
5653}

◆ GetUserDefaultUILanguage()

LANGID WINAPI GetUserDefaultUILanguage ( void  )

◆ GetUserGeoID()

GEOID WINAPI GetUserGeoID ( GEOCLASS  GeoClass)

Definition at line 4837 of file locale.c.

4838{
4840 static const WCHAR geoW[] = {'G','e','o',0};
4841 static const WCHAR nationW[] = {'N','a','t','i','o','n',0};
4842 WCHAR bufferW[40], *end;
4843 DWORD count;
4844 HANDLE hkey, hSubkey = 0;
4845 UNICODE_STRING keyW;
4847 RtlInitUnicodeString( &keyW, nationW );
4848 count = sizeof(bufferW);
4849
4850 if(!(hkey = create_registry_key())) return ret;
4851
4852 switch( GeoClass ){
4853 case GEOCLASS_NATION:
4854 if ((hSubkey = NLS_RegOpenKey(hkey, geoW)))
4855 {
4856 if((NtQueryValueKey(hSubkey, &keyW, KeyValuePartialInformation,
4857 bufferW, count, &count) == STATUS_SUCCESS ) && info->DataLength)
4858 ret = strtolW((LPCWSTR)info->Data, &end, 10);
4859 }
4860 break;
4861 case GEOCLASS_REGION:
4862 FIXME("GEOCLASS_REGION not handled yet\n");
4863 break;
4864 }
4865
4866 NtClose(hkey);
4867 if (hSubkey) NtClose(hSubkey);
4868 return ret;
4869}
static HANDLE NLS_RegOpenKey(HANDLE hRootKey, LPCWSTR szKeyName)
Definition: locale.c:4352
ULONG GEOID
Definition: mui.h:28
#define GEOID_NOT_AVAILABLE
Definition: winnls.h:13

Referenced by CreateLocationsList(), and SetUserLocaleName().

◆ IdnToAscii()

INT WINAPI IdnToAscii ( DWORD  dwFlags,
LPCWSTR  lpUnicodeCharStr,
INT  cchUnicodeChar,
LPWSTR  lpASCIICharStr,
INT  cchASCIIChar 
)

Definition at line 5702 of file locale.c.

5704{
5705 static const WCHAR prefixW[] = {'x','n','-','-'};
5706
5707 WCHAR *norm_str;
5708 INT i, label_start, label_end, norm_len, out_label, out = 0;
5709
5710 TRACE("%x %p %d %p %d\n", dwFlags, lpUnicodeCharStr, cchUnicodeChar,
5711 lpASCIICharStr, cchASCIIChar);
5712
5713 norm_len = IdnToNameprepUnicode(dwFlags, lpUnicodeCharStr, cchUnicodeChar, NULL, 0);
5714 if(!norm_len)
5715 return 0;
5716 norm_str = HeapAlloc(GetProcessHeap(), 0, norm_len*sizeof(WCHAR));
5717 if(!norm_str) {
5719 return 0;
5720 }
5721 norm_len = IdnToNameprepUnicode(dwFlags, lpUnicodeCharStr,
5722 cchUnicodeChar, norm_str, norm_len);
5723 if(!norm_len) {
5724 HeapFree(GetProcessHeap(), 0, norm_str);
5725 return 0;
5726 }
5727
5728 for(label_start=0; label_start<norm_len;) {
5729 INT n = INIT_N, bias = INIT_BIAS;
5730 INT delta = 0, b = 0, h;
5731
5732 out_label = out;
5733 for(i=label_start; i<norm_len && norm_str[i]!='.' &&
5734 norm_str[i]!=0x3002 && norm_str[i]!='\0'; i++)
5735 if(norm_str[i] < 0x80)
5736 b++;
5737 label_end = i;
5738
5739 if(b == label_end-label_start) {
5740 if(label_end < norm_len)
5741 b++;
5742 if(!lpASCIICharStr) {
5743 out += b;
5744 }else if(out+b <= cchASCIIChar) {
5745 memcpy(lpASCIICharStr+out, norm_str+label_start, b*sizeof(WCHAR));
5746 out += b;
5747 }else {
5748 HeapFree(GetProcessHeap(), 0, norm_str);
5750 return 0;
5751 }
5752 label_start = label_end+1;
5753 continue;
5754 }
5755
5756 if(!lpASCIICharStr) {
5757 out += 5+b; /* strlen(xn--...-) */
5758 }else if(out+5+b <= cchASCIIChar) {
5759 memcpy(lpASCIICharStr+out, prefixW, sizeof(prefixW));
5760 out += 4;
5761 for(i=label_start; i<label_end; i++)
5762 if(norm_str[i] < 0x80)
5763 lpASCIICharStr[out++] = norm_str[i];
5764 lpASCIICharStr[out++] = '-';
5765 }else {
5766 HeapFree(GetProcessHeap(), 0, norm_str);
5768 return 0;
5769 }
5770 if(!b)
5771 out--;
5772
5773 for(h=b; h<label_end-label_start;) {
5774 INT m = 0xffff, q, k;
5775
5776 for(i=label_start; i<label_end; i++) {
5777 if(norm_str[i]>=n && m>norm_str[i])
5778 m = norm_str[i];
5779 }
5780 delta += (m-n)*(h+1);
5781 n = m;
5782
5783 for(i=label_start; i<label_end; i++) {
5784 if(norm_str[i] < n) {
5785 delta++;
5786 }else if(norm_str[i] == n) {
5787 for(q=delta, k=BASE; ; k+=BASE) {
5788 INT t = k<=bias ? TMIN : k>=bias+TMAX ? TMAX : k-bias;
5789 INT disp = q<t ? q : t+(q-t)%(BASE-t);
5790 if(!lpASCIICharStr) {
5791 out++;
5792 }else if(out+1 <= cchASCIIChar) {
5793 lpASCIICharStr[out++] = disp<='z'-'a' ?
5794 'a'+disp : '0'+disp-'z'+'a'-1;
5795 }else {
5796 HeapFree(GetProcessHeap(), 0, norm_str);
5798 return 0;
5799 }
5800 if(q < t)
5801 break;
5802 q = (q-t)/(BASE-t);
5803 }
5804 bias = adapt(delta, h+1, h==b);
5805 delta = 0;
5806 h++;
5807 }
5808 }
5809 delta++;
5810 n++;
5811 }
5812
5813 if(out-out_label > 63) {
5814 HeapFree(GetProcessHeap(), 0, norm_str);
5816 return 0;
5817 }
5818
5819 if(label_end < norm_len) {
5820 if(!lpASCIICharStr) {
5821 out++;
5822 }else if(out+1 <= cchASCIIChar) {
5823 lpASCIICharStr[out++] = norm_str[label_end] ? '.' : 0;
5824 }else {
5825 HeapFree(GetProcessHeap(), 0, norm_str);
5827 return 0;
5828 }
5829 }
5830 label_start = label_end+1;
5831 }
5832
5833 HeapFree(GetProcessHeap(), 0, norm_str);
5834 return out;
5835}
#define ERROR_INVALID_NAME
Definition: compat.h:103
static INT adapt(INT delta, INT numpoints, BOOL firsttime)
Definition: locale.c:5686
INT WINAPI IdnToNameprepUnicode(DWORD dwFlags, LPCWSTR lpUnicodeCharStr, INT cchUnicodeChar, LPWSTR lpNameprepCharStr, INT cchNameprepChar)
Definition: locale.c:5840
GLdouble GLdouble t
Definition: gl.h:2047
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLfloat bias
Definition: glext.h:7909
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
const GLfloat * m
Definition: glext.h:10848
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define b
Definition: ke_i.h:79
static FILE * out
Definition: regtests2xml.c:44

Referenced by InitFunctionPointers().

◆ IdnToNameprepUnicode()

INT WINAPI IdnToNameprepUnicode ( DWORD  dwFlags,
LPCWSTR  lpUnicodeCharStr,
INT  cchUnicodeChar,
LPWSTR  lpNameprepCharStr,
INT  cchNameprepChar 
)

Definition at line 5840 of file locale.c.

5842{
5843 enum {
5844 UNASSIGNED = 0x1,
5845 PROHIBITED = 0x2,
5846 BIDI_RAL = 0x4,
5847 BIDI_L = 0x8
5848 };
5849
5850 extern const unsigned short nameprep_char_type[] DECLSPEC_HIDDEN;
5851 extern const WCHAR nameprep_mapping[] DECLSPEC_HIDDEN;
5852 const WCHAR *ptr;
5853 WORD flags;
5854 WCHAR buf[64], *map_str, norm_str[64], ch;
5855 DWORD i, map_len, norm_len, mask, label_start, label_end, out = 0;
5856 BOOL have_bidi_ral, prohibit_bidi_ral, ascii_only;
5857
5858 TRACE("%x %p %d %p %d\n", dwFlags, lpUnicodeCharStr, cchUnicodeChar,
5859 lpNameprepCharStr, cchNameprepChar);
5860
5861 if(dwFlags & ~(IDN_ALLOW_UNASSIGNED|IDN_USE_STD3_ASCII_RULES)) {
5863 return 0;
5864 }
5865
5866 if(!lpUnicodeCharStr || cchUnicodeChar<-1) {
5868 return 0;
5869 }
5870
5871 if(cchUnicodeChar == -1)
5872 cchUnicodeChar = strlenW(lpUnicodeCharStr)+1;
5873 if(!cchUnicodeChar || (cchUnicodeChar==1 && lpUnicodeCharStr[0]==0)) {
5875 return 0;
5876 }
5877
5878 for(label_start=0; label_start<cchUnicodeChar;) {
5879 ascii_only = TRUE;
5880 for(i=label_start; i<cchUnicodeChar; i++) {
5881 ch = lpUnicodeCharStr[i];
5882
5883 if(i!=cchUnicodeChar-1 && !ch) {
5885 return 0;
5886 }
5887 /* check if ch is one of label separators defined in RFC3490 */
5888 if(!ch || ch=='.' || ch==0x3002 || ch==0xff0e || ch==0xff61)
5889 break;
5890
5891 if(ch > 0x7f) {
5892 ascii_only = FALSE;
5893 continue;
5894 }
5895
5896 if((dwFlags&IDN_USE_STD3_ASCII_RULES) == 0)
5897 continue;
5898 if((ch>='a' && ch<='z') || (ch>='A' && ch<='Z')
5899 || (ch>='0' && ch<='9') || ch=='-')
5900 continue;
5901
5903 return 0;
5904 }
5905 label_end = i;
5906 /* last label may be empty */
5907 if(label_start==label_end && ch) {
5909 return 0;
5910 }
5911
5912 if((dwFlags&IDN_USE_STD3_ASCII_RULES) && (lpUnicodeCharStr[label_start]=='-' ||
5913 lpUnicodeCharStr[label_end-1]=='-')) {
5915 return 0;
5916 }
5917
5918 if(ascii_only) {
5919 /* maximal label length is 63 characters */
5920 if(label_end-label_start > 63) {
5922 return 0;
5923 }
5924 if(label_end < cchUnicodeChar)
5925 label_end++;
5926
5927 if(!lpNameprepCharStr) {
5928 out += label_end-label_start;
5929 }else if(out+label_end-label_start <= cchNameprepChar) {
5930 memcpy(lpNameprepCharStr+out, lpUnicodeCharStr+label_start,
5931 (label_end-label_start)*sizeof(WCHAR));
5932 if(lpUnicodeCharStr[label_end-1] > 0x7f)
5933 lpNameprepCharStr[out+label_end-label_start-1] = '.';
5934 out += label_end-label_start;
5935 }else {
5937 return 0;
5938 }
5939
5940 label_start = label_end;
5941 continue;
5942 }
5943
5944 map_len = 0;
5945 for(i=label_start; i<label_end; i++) {
5946 ch = lpUnicodeCharStr[i];
5948 ptr = nameprep_mapping + ptr[(ch>>4)&0x0f] + 3*(ch&0x0f);
5949
5950 if(!ptr[0]) map_len++;
5951 else if(!ptr[1]) map_len++;
5952 else if(!ptr[2]) map_len += 2;
5953 else if(ptr[0]!=0xffff || ptr[1]!=0xffff || ptr[2]!=0xffff) map_len += 3;
5954 }
5955 if(map_len*sizeof(WCHAR) > sizeof(buf)) {
5956 map_str = HeapAlloc(GetProcessHeap(), 0, map_len*sizeof(WCHAR));
5957 if(!map_str) {
5959 return 0;
5960 }
5961 }else {
5962 map_str = buf;
5963 }
5964 map_len = 0;
5965 for(i=label_start; i<label_end; i++) {
5966 ch = lpUnicodeCharStr[i];
5968 ptr = nameprep_mapping + ptr[(ch>>4)&0x0f] + 3*(ch&0x0f);
5969
5970 if(!ptr[0]) {
5971 map_str[map_len++] = ch;
5972 }else if(!ptr[1]) {
5973 map_str[map_len++] = ptr[0];
5974 }else if(!ptr[2]) {
5975 map_str[map_len++] = ptr[0];
5976 map_str[map_len++] = ptr[1];
5977 }else if(ptr[0]!=0xffff || ptr[1]!=0xffff || ptr[2]!=0xffff) {
5978 map_str[map_len++] = ptr[0];
5979 map_str[map_len++] = ptr[1];
5980 map_str[map_len++] = ptr[2];
5981 }
5982 }
5983
5984 norm_len = FoldStringW(MAP_FOLDCZONE, map_str, map_len,
5985 norm_str, sizeof(norm_str)/sizeof(WCHAR)-1);
5986 if(map_str != buf)
5987 HeapFree(GetProcessHeap(), 0, map_str);
5988 if(!norm_len) {
5991 return 0;
5992 }
5993
5994 if(label_end < cchUnicodeChar) {
5995 norm_str[norm_len++] = lpUnicodeCharStr[label_end] ? '.' : 0;
5996 label_end++;
5997 }
5998
5999 if(!lpNameprepCharStr) {
6000 out += norm_len;
6001 }else if(out+norm_len <= cchNameprepChar) {
6002 memcpy(lpNameprepCharStr+out, norm_str, norm_len*sizeof(WCHAR));
6003 out += norm_len;
6004 }else {
6006 return 0;
6007 }
6008
6009 have_bidi_ral = prohibit_bidi_ral = FALSE;
6010 mask = PROHIBITED;
6011 if((dwFlags&IDN_ALLOW_UNASSIGNED) == 0)
6012 mask |= UNASSIGNED;
6013 for(i=0; i<norm_len; i++) {
6014 ch = norm_str[i];
6016
6017 if(flags & mask) {
6018 SetLastError((flags & PROHIBITED) ? ERROR_INVALID_NAME
6020 return 0;
6021 }
6022
6023 if(flags & BIDI_RAL)
6024 have_bidi_ral = TRUE;
6025 if(flags & BIDI_L)
6026 prohibit_bidi_ral = TRUE;
6027 }
6028
6029 if(have_bidi_ral) {
6030 ch = norm_str[0];
6032 if((flags & BIDI_RAL) == 0)
6033 prohibit_bidi_ral = TRUE;
6034
6035 ch = norm_str[norm_len-1];
6037 if((flags & BIDI_RAL) == 0)
6038 prohibit_bidi_ral = TRUE;
6039 }
6040
6041 if(have_bidi_ral && prohibit_bidi_ral) {
6043 return 0;
6044 }
6045
6046 label_start = label_end;
6047 }
6048
6049 return out;
6050}
#define DECLSPEC_HIDDEN
Definition: precomp.h:8
static unsigned short get_table_entry(const unsigned short *table, WCHAR ch)
Definition: locale.c:276
GLenum GLint GLuint mask
Definition: glext.h:6028
const unsigned short nameprep_char_type[4432]
Definition: nameprep.c:5
const unsigned short nameprep_mapping[5856]
Definition: nameprep.c:565
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_NO_UNICODE_TRANSLATION
Definition: winerror.h:649

Referenced by IdnToAscii(), and InitFunctionPointers().

◆ IdnToUnicode()

INT WINAPI IdnToUnicode ( DWORD  dwFlags,
LPCWSTR  lpASCIICharStr,
INT  cchASCIIChar,
LPWSTR  lpUnicodeCharStr,
INT  cchUnicodeChar 
)

Definition at line 6055 of file locale.c.

6057{
6058 extern const unsigned short nameprep_char_type[];
6059
6060 INT i, label_start, label_end, out_label, out = 0;
6061 WCHAR ch;
6062
6063 TRACE("%x %p %d %p %d\n", dwFlags, lpASCIICharStr, cchASCIIChar,
6064 lpUnicodeCharStr, cchUnicodeChar);
6065
6066 for(label_start=0; label_start<cchASCIIChar;) {
6067 INT n = INIT_N, pos = 0, old_pos, w, k, bias = INIT_BIAS, delim=0, digit, t;
6068
6069 out_label = out;
6070 for(i=label_start; i<cchASCIIChar; i++) {
6071 ch = lpASCIICharStr[i];
6072
6073 if(ch>0x7f || (i!=cchASCIIChar-1 && !ch)) {
6075 return 0;
6076 }
6077
6078 if(!ch || ch=='.')
6079 break;
6080 if(ch == '-')
6081 delim = i;
6082
6083 if((dwFlags&IDN_USE_STD3_ASCII_RULES) == 0)
6084 continue;
6085 if((ch>='a' && ch<='z') || (ch>='A' && ch<='Z')
6086 || (ch>='0' && ch<='9') || ch=='-')
6087 continue;
6088
6090 return 0;
6091 }
6092 label_end = i;
6093 /* last label may be empty */
6094 if(label_start==label_end && ch) {
6096 return 0;
6097 }
6098
6099 if((dwFlags&IDN_USE_STD3_ASCII_RULES) && (lpASCIICharStr[label_start]=='-' ||
6100 lpASCIICharStr[label_end-1]=='-')) {
6102 return 0;
6103 }
6104 if(label_end-label_start > 63) {
6106 return 0;
6107 }
6108
6109 if(label_end-label_start<4 ||
6110 tolowerW(lpASCIICharStr[label_start])!='x' ||
6111 tolowerW(lpASCIICharStr[label_start+1])!='n' ||
6112 lpASCIICharStr[label_start+2]!='-' || lpASCIICharStr[label_start+3]!='-') {
6113 if(label_end < cchASCIIChar)
6114 label_end++;
6115
6116 if(!lpUnicodeCharStr) {
6117 out += label_end-label_start;
6118 }else if(out+label_end-label_start <= cchUnicodeChar) {
6119 memcpy(lpUnicodeCharStr+out, lpASCIICharStr+label_start,
6120 (label_end-label_start)*sizeof(WCHAR));
6121 out += label_end-label_start;
6122 }else {
6124 return 0;
6125 }
6126
6127 label_start = label_end;
6128 continue;
6129 }
6130
6131 if(delim == label_start+3)
6132 delim++;
6133 if(!lpUnicodeCharStr) {
6134 out += delim-label_start-4;
6135 }else if(out+delim-label_start-4 <= cchUnicodeChar) {
6136 memcpy(lpUnicodeCharStr+out, lpASCIICharStr+label_start+4,
6137 (delim-label_start-4)*sizeof(WCHAR));
6138 out += delim-label_start-4;
6139 }else {
6141 return 0;
6142 }
6143 if(out != out_label)
6144 delim++;
6145
6146 for(i=delim; i<label_end;) {
6147 old_pos = pos;
6148 w = 1;
6149 for(k=BASE; ; k+=BASE) {
6150 ch = i<label_end ? tolowerW(lpASCIICharStr[i++]) : 0;
6151 if((ch<'a' || ch>'z') && (ch<'0' || ch>'9')) {
6153 return 0;
6154 }
6155 digit = ch<='9' ? ch-'0'+'z'-'a'+1 : ch-'a';
6156 pos += digit*w;
6157 t = k<=bias ? TMIN : k>=bias+TMAX ? TMAX : k-bias;
6158 if(digit < t)
6159 break;
6160 w *= BASE-t;
6161 }
6162 bias = adapt(pos-old_pos, out-out_label+1, old_pos==0);
6163 n += pos/(out-out_label+1);
6164 pos %