ReactOS 0.4.16-dev-1040-g85afe48
getqloc_downlevel.cpp File Reference
#include <corecrt_internal.h>
#include <locale.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for getqloc_downlevel.cpp:

Go to the source code of this file.

Classes

struct  tagRGLOCINFO
 

Macros

#define __LCID_DEFAULT   0x1
 
#define __LCID_PRIMARY   0x2
 
#define __LCID_FULL   0x4
 
#define __LCID_LANGUAGE   0x100
 
#define __LCID_EXISTS   0x200
 

Typedefs

typedef struct tagRGLOCINFO RGLOCINFO
 

Functions

static bool TranslateName (const __crt_locale_string_table *, int, const wchar_t **)
 
static void GetLcidFromLangCountry (__crt_qualified_locale_data_downlevel *_psetloc_downlevel_data)
 
static BOOL CALLBACK LangCountryEnumProc (_In_z_ PWSTR)
 
static void GetLcidFromLanguage (__crt_qualified_locale_data_downlevel *_psetloc_downlevel_data)
 
static BOOL CALLBACK LanguageEnumProc (_In_z_ PWSTR)
 
static void GetLcidFromCountry (__crt_qualified_locale_data_downlevel *_psetloc_downlevel_data)
 
static BOOL CALLBACK CountryEnumProc (_In_z_ PWSTR)
 
static void GetLcidFromDefault (__crt_qualified_locale_data_downlevel *_psetloc_downlevel_data)
 
static int ProcessCodePage (LPCWSTR lpCodePageStr, __crt_qualified_locale_data_downlevel *_psetloc_downlevel_data)
 
static BOOL TestDefaultCountry (LCID)
 
static BOOL TestDefaultLanguage (LCID lcid, BOOL bTestPrimary, __crt_qualified_locale_data_downlevel *_psetloc_downlevel_data)
 
static LCID LcidFromHexString (_In_z_ PCWSTR)
 
static int GetPrimaryLen (wchar_t const *)
 
 __declspec (selectany) LANGID const __rglangidNotDefault[]
 
BOOL __cdecl __acrt_get_qualified_locale_downlevel (const __crt_locale_strings *lpInStr, UINT *lpOutCodePage, __crt_locale_strings *lpOutStr)
 

Macro Definition Documentation

◆ __LCID_DEFAULT

#define __LCID_DEFAULT   0x1

Definition at line 18 of file getqloc_downlevel.cpp.

◆ __LCID_EXISTS

#define __LCID_EXISTS   0x200

Definition at line 22 of file getqloc_downlevel.cpp.

◆ __LCID_FULL

#define __LCID_FULL   0x4

Definition at line 20 of file getqloc_downlevel.cpp.

◆ __LCID_LANGUAGE

#define __LCID_LANGUAGE   0x100

Definition at line 21 of file getqloc_downlevel.cpp.

◆ __LCID_PRIMARY

#define __LCID_PRIMARY   0x2

Definition at line 19 of file getqloc_downlevel.cpp.

Typedef Documentation

◆ RGLOCINFO

Function Documentation

◆ __acrt_get_qualified_locale_downlevel()

BOOL __cdecl __acrt_get_qualified_locale_downlevel ( const __crt_locale_strings lpInStr,
UINT lpOutCodePage,
__crt_locale_strings lpOutStr 
)

Definition at line 89 of file getqloc_downlevel.cpp.

90{
91 int iCodePage;
92
93 // Get setloc data from per thread data struct
95
96 // Set downlevel setloc data in per thread data struct for use by LCID downlevel APIs
98 __crt_qualified_locale_data_downlevel* _psetloc_downlevel_data;
99
100 memset(&downlevel_setloc, '\0', sizeof(__crt_qualified_locale_data_downlevel));
101 _psetloc_downlevel_data = __acrt_getptd()->_setloc_downlevel_data = &downlevel_setloc;
102
103 // initialize pointer to call locale info routine based on operating system
104
105 _psetloc_data->pchLanguage = lpInStr->szLanguage;
106
107 // convert non-NLS country strings to three-letter abbreviations
108 _psetloc_data->pchCountry = lpInStr->szCountry;
109 if (_psetloc_data->pchCountry && *_psetloc_data->pchCountry)
111 static_cast<int>(__acrt_rg_country_count - 1),
112 &_psetloc_data->pchCountry);
113
114 _psetloc_downlevel_data->iLcidState = 0;
115
116 if (_psetloc_data->pchLanguage && *_psetloc_data->pchLanguage)
117 {
118 if (_psetloc_data->pchCountry && *_psetloc_data->pchCountry)
119 {
120 // both language and country strings defined
121 GetLcidFromLangCountry(_psetloc_downlevel_data);
122 }
123 else
124 {
125 // language string defined, but country string undefined
126 GetLcidFromLanguage(_psetloc_downlevel_data);
127 }
128
129 if (!_psetloc_downlevel_data->iLcidState) {
130 // first attempt failed, try substituting the language name
131 // convert non-NLS language strings to three-letter abbrevs
133 static_cast<int>(__acrt_rg_language_count - 1),
134 &_psetloc_data->pchLanguage))
135 {
136 if (_psetloc_data->pchCountry && *_psetloc_data->pchCountry)
137 {
138 GetLcidFromLangCountry(_psetloc_downlevel_data);
139 }
140 else
141 {
142 GetLcidFromLanguage(_psetloc_downlevel_data);
143 }
144 }
145 }
146 }
147 else
148 {
149 if (_psetloc_data->pchCountry && *_psetloc_data->pchCountry)
150 {
151 // country string defined, but language string undefined
152 GetLcidFromCountry(_psetloc_downlevel_data);
153 }
154 else
155 {
156 // both language and country strings undefined
157 GetLcidFromDefault(_psetloc_downlevel_data);
158 }
159 }
160
161 // test for error in LCID processing
162 if (!_psetloc_downlevel_data->iLcidState)
163 return FALSE;
164
165 // process codepage value
166 iCodePage = ProcessCodePage(lpInStr ? lpInStr->szCodePage: nullptr, _psetloc_downlevel_data);
167
168 // verify codepage validity
169 if (!iCodePage || !IsValidCodePage((WORD)iCodePage))
170 return FALSE;
171
172 // verify locale is installed
173 if (!IsValidLocale(_psetloc_downlevel_data->lcidLanguage, LCID_INSTALLED))
174 return FALSE;
175
176 // set codepage
177 if (lpOutCodePage)
178 {
179 *lpOutCodePage = (UINT)iCodePage;
180 }
181
182 // store locale name in cache
184 _psetloc_downlevel_data->lcidLanguage,
185 _psetloc_data->_cacheLocaleName,
186 (int)_countof(_psetloc_data->_cacheLocaleName),
187 0);
188
189 // set locale name and codepage results
190 if (lpOutStr)
191 {
193 _psetloc_downlevel_data->lcidLanguage,
194 lpOutStr->szLocaleName,
195 (int)_countof(lpOutStr->szLocaleName),
196 0);
197
198 if (GetLocaleInfoW(_psetloc_downlevel_data->lcidLanguage, LOCALE_SENGLANGUAGE,
199 lpOutStr->szLanguage, MAX_LANG_LEN) == 0)
200 return FALSE;
201
202 if (GetLocaleInfoW(_psetloc_downlevel_data->lcidCountry, LOCALE_SENGCOUNTRY,
203 lpOutStr->szCountry, MAX_CTRY_LEN) == 0)
204 return FALSE;
205
206 _itow_s((int)iCodePage, (wchar_t *)lpOutStr->szCodePage, MAX_CP_LEN, 10);
207 }
208
209 return TRUE;
210}
#define MAX_LANG_LEN
#define MAX_CP_LEN
#define MAX_CTRY_LEN
__acrt_ptd *__cdecl __acrt_getptd(void)
__crt_locale_string_table const __acrt_rg_language[]
__crt_locale_string_table const __acrt_rg_country[]
size_t const __acrt_rg_language_count
int WINAPI __acrt_LCIDToLocaleName(_In_ LCID locale, _Out_writes_opt_(name_count) LPWSTR name, _In_ int name_count, _In_ DWORD flags)
size_t const __acrt_rg_country_count
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI IsValidCodePage(UINT codepage)
Definition: locale.c:2079
BOOL WINAPI IsValidLocale(LCID lcid, DWORD flags)
Definition: locale.c:2923
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1666
unsigned short WORD
Definition: ntddk_ex.h:93
static void GetLcidFromDefault(__crt_qualified_locale_data_downlevel *_psetloc_downlevel_data)
static void GetLcidFromLangCountry(__crt_qualified_locale_data_downlevel *_psetloc_downlevel_data)
static void GetLcidFromCountry(__crt_qualified_locale_data_downlevel *_psetloc_downlevel_data)
static bool TranslateName(const __crt_locale_string_table *, int, const wchar_t **)
static int ProcessCodePage(LPCWSTR lpCodePageStr, __crt_qualified_locale_data_downlevel *_psetloc_downlevel_data)
static void GetLcidFromLanguage(__crt_qualified_locale_data_downlevel *_psetloc_downlevel_data)
int CDECL _itow_s(int value, wchar_t *str, size_t size, int radix)
Definition: itow.c:222
unsigned int UINT
Definition: ndis.h:50
#define memset(x, y, z)
Definition: compat.h:39
#define _countof(array)
Definition: sndvol32.h:70
__crt_qualified_locale_data_downlevel * _setloc_downlevel_data
__crt_qualified_locale_data _setloc_data
wchar_t szLocaleName[LOCALE_NAME_MAX_LENGTH]
wchar_t szLanguage[MAX_LANG_LEN]
wchar_t szCountry[MAX_CTRY_LEN]
wchar_t szCodePage[MAX_CP_LEN]
wchar_t _cacheLocaleName[LOCALE_NAME_MAX_LENGTH]
#define LCID_INSTALLED
Definition: winnls.h:203
#define LOCALE_SENGLANGUAGE
Definition: winnls.h:27
#define LOCALE_SENGCOUNTRY
Definition: winnls.h:33

Referenced by _expandlocale().

◆ __declspec()

__declspec ( selectany  ) const

◆ CountryEnumProc()

static BOOL CALLBACK CountryEnumProc ( _In_z_ PWSTR  lpLcidString)
static

Definition at line 619 of file getqloc_downlevel.cpp.

620{
623 LCID lcid = LcidFromHexString(lpLcidString);
624 wchar_t rgcInfo[120];
625
626 // test locale for country specified
627 if (GetLocaleInfoW(lcid, _psetloc_data->bAbbrevCountry ? LOCALE_SABBREVCTRYNAME
629 rgcInfo, _countof(rgcInfo)) == 0)
630 {
631 // set error condition and exit
632 _psetloc_downlevel_data->iLcidState = 0;
633 return TRUE;
634 }
635 if (!_wcsicmp(_psetloc_data->pchCountry, rgcInfo))
636 {
637 // language matched - test if locale country is default
638 if (TestDefaultCountry(lcid))
639 {
640 // this locale has the default language
641 _psetloc_downlevel_data->lcidLanguage = _psetloc_downlevel_data->lcidCountry = lcid;
642 _psetloc_downlevel_data->iLcidState |= __LCID_FULL;
643 }
644 }
645 return (_psetloc_downlevel_data->iLcidState & __LCID_FULL) == 0;
646}
static LCID LcidFromHexString(_In_z_ PCWSTR)
#define __LCID_FULL
static BOOL TestDefaultCountry(LCID)
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
DWORD LCID
Definition: nls.h:13
#define LOCALE_SABBREVCTRYNAME
Definition: winnls.h:35

Referenced by GetLcidFromCountry().

◆ GetLcidFromCountry()

static void GetLcidFromCountry ( __crt_qualified_locale_data_downlevel _psetloc_downlevel_data)
static

Definition at line 587 of file getqloc_downlevel.cpp.

588{
590 _psetloc_data->bAbbrevCountry = wcslen(_psetloc_data->pchCountry) == 3;
591
593
594 // locale value is invalid if the country was not defined or
595 // no default language was found
596 if (!(_psetloc_downlevel_data->iLcidState & __LCID_FULL))
597 _psetloc_downlevel_data->iLcidState = 0;
598}
BOOL WINAPI EnumSystemLocalesW(LOCALE_ENUMPROCW lpfnLocaleEnum, DWORD dwFlags)
Definition: locale.c:2999
static BOOL CALLBACK CountryEnumProc(_In_z_ PWSTR)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by __acrt_get_qualified_locale_downlevel().

◆ GetLcidFromDefault()

static void GetLcidFromDefault ( __crt_qualified_locale_data_downlevel _psetloc_downlevel_data)
static

Definition at line 664 of file getqloc_downlevel.cpp.

665{
666 _psetloc_downlevel_data->iLcidState |= (__LCID_FULL | __LCID_LANGUAGE);
667 _psetloc_downlevel_data->lcidLanguage = _psetloc_downlevel_data->lcidCountry = GetUserDefaultLCID();
668}
LCID WINAPI GetUserDefaultLCID(void)
Definition: locale.c:1211
#define __LCID_LANGUAGE

Referenced by __acrt_get_qualified_locale_downlevel().

◆ GetLcidFromLangCountry()

static void GetLcidFromLangCountry ( __crt_qualified_locale_data_downlevel _psetloc_downlevel_data)
static

Definition at line 280 of file getqloc_downlevel.cpp.

281{
283
284 // initialize static variables for callback use
285 _psetloc_data->bAbbrevLanguage = wcslen(_psetloc_data->pchLanguage) == 3;
286 _psetloc_data->bAbbrevCountry = wcslen(_psetloc_data->pchCountry) == 3;
287 _psetloc_downlevel_data->lcidLanguage = 0;
288 _psetloc_data->iPrimaryLen = _psetloc_data->bAbbrevLanguage ?
289 2 : GetPrimaryLen(_psetloc_data->pchLanguage);
290
292
293 // locale value is invalid if the language was not installed or the language
294 // was not available for the country specified
295 if (!(_psetloc_downlevel_data->iLcidState & __LCID_LANGUAGE) ||
296 !(_psetloc_downlevel_data->iLcidState & __LCID_EXISTS) ||
297 !(_psetloc_downlevel_data->iLcidState & (__LCID_FULL |
300 _psetloc_downlevel_data->iLcidState = 0;
301}
static BOOL CALLBACK LangCountryEnumProc(_In_z_ PWSTR)
#define __LCID_EXISTS
#define __LCID_PRIMARY
static int GetPrimaryLen(wchar_t const *)
#define __LCID_DEFAULT

Referenced by __acrt_get_qualified_locale_downlevel().

◆ GetLcidFromLanguage()

static void GetLcidFromLanguage ( __crt_qualified_locale_data_downlevel _psetloc_downlevel_data)
static

Definition at line 488 of file getqloc_downlevel.cpp.

489{
491
492 // initialize static variables for callback use
493 _psetloc_data->bAbbrevLanguage = wcslen(_psetloc_data->pchLanguage) == 3;
494 _psetloc_data->iPrimaryLen = _psetloc_data->bAbbrevLanguage ? 2 : GetPrimaryLen(_psetloc_data->pchLanguage);
495
497
498 // locale value is invalid if the language was not installed
499 // or the language was not available for the country specified
500 if (!(_psetloc_downlevel_data->iLcidState & __LCID_FULL))
501 _psetloc_downlevel_data->iLcidState = 0;
502}
static BOOL CALLBACK LanguageEnumProc(_In_z_ PWSTR)

Referenced by __acrt_get_qualified_locale_downlevel().

◆ GetPrimaryLen()

static int GetPrimaryLen ( wchar_t const pchLanguage)
static

Definition at line 837 of file getqloc_downlevel.cpp.

838{
839 int len = 0;
840 wchar_t ch;
841
842 ch = *pchLanguage++;
843 while ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'))
844 {
845 len++;
846 ch = *pchLanguage++;
847 }
848
849 return len;
850}
GLenum GLsizei len
Definition: glext.h:6722

Referenced by GetLcidFromLangCountry(), GetLcidFromLanguage(), and TestDefaultLanguage().

◆ LangCountryEnumProc()

static BOOL CALLBACK LangCountryEnumProc ( _In_z_ PWSTR  lpLcidString)
static

Definition at line 331 of file getqloc_downlevel.cpp.

332{
335 LCID lcid = LcidFromHexString(lpLcidString);
336 wchar_t rgcInfo[120];
337
338 // test locale country against input value
339 if (GetLocaleInfoW(lcid,
340 _psetloc_data->bAbbrevCountry ?
342 rgcInfo, _countof(rgcInfo)) == 0)
343 {
344 // set error condition and exit
345 _psetloc_downlevel_data->iLcidState = 0;
346 return TRUE;
347 }
348 if (!_wcsicmp(_psetloc_data->pchCountry, rgcInfo))
349 {
350 // country matched - test for language match
351 if (GetLocaleInfoW(lcid,
352 _psetloc_data->bAbbrevLanguage ?
354 rgcInfo, _countof(rgcInfo)) == 0)
355 {
356 // set error condition and exit
357 _psetloc_downlevel_data->iLcidState = 0;
358 return TRUE;
359 }
360 if (!_wcsicmp(_psetloc_data->pchLanguage, rgcInfo))
361 {
362 // language matched also - set state and value
363 _psetloc_downlevel_data->iLcidState |= (__LCID_FULL |
366 _psetloc_downlevel_data->lcidLanguage = _psetloc_downlevel_data->lcidCountry = lcid;
367 }
368
369 // test if match already for primary langauage
370 else if (!(_psetloc_downlevel_data->iLcidState & __LCID_PRIMARY))
371 {
372 // if not, use _psetloc_data->iPrimaryLen to partial match language string
373 if (_psetloc_data->iPrimaryLen && !_wcsnicmp(_psetloc_data->pchLanguage, rgcInfo, _psetloc_data->iPrimaryLen))
374 {
375 // primary language matched - set state and country LCID
376 _psetloc_downlevel_data->iLcidState |= __LCID_PRIMARY;
377 _psetloc_downlevel_data->lcidCountry = lcid;
378
379 // if language is primary only (no subtype), set language LCID
380 if ((int)wcslen(_psetloc_data->pchLanguage) == _psetloc_data->iPrimaryLen)
381 _psetloc_downlevel_data->lcidLanguage = lcid;
382 }
383
384 // test if default language already defined
385 else if (!(_psetloc_downlevel_data->iLcidState & __LCID_DEFAULT))
386 {
387 // if not, test if locale language is default for country
388 if (TestDefaultCountry(lcid))
389 {
390 // default language for country - set state, value
391 _psetloc_downlevel_data->iLcidState |= __LCID_DEFAULT;
392 _psetloc_downlevel_data->lcidCountry = lcid;
393 }
394 }
395 }
396 }
397 // test if input language both exists and default primary language defined
398 if ((_psetloc_downlevel_data->iLcidState & (__LCID_LANGUAGE | __LCID_EXISTS)) !=
400 {
401 // test language match to determine whether it is installed
402 if (GetLocaleInfoW(lcid, _psetloc_data->bAbbrevLanguage ? LOCALE_SABBREVLANGNAME
404 rgcInfo, _countof(rgcInfo)) == 0)
405 {
406 // set error condition and exit
407 _psetloc_downlevel_data->iLcidState = 0;
408 return TRUE;
409 }
410
411 if (!_wcsicmp(_psetloc_data->pchLanguage, rgcInfo))
412 {
413 // language matched - set bit for existance
414 _psetloc_downlevel_data->iLcidState |= __LCID_EXISTS;
415
416 if (_psetloc_data->bAbbrevLanguage)
417 {
418 // abbreviation - set state
419 // also set language LCID if not set already
420 _psetloc_downlevel_data->iLcidState |= __LCID_LANGUAGE;
421 if (!_psetloc_downlevel_data->lcidLanguage)
422 _psetloc_downlevel_data->lcidLanguage = lcid;
423 }
424
425 // test if language is primary only (no sublanguage)
426 else if (_psetloc_data->iPrimaryLen && ((int)wcslen(_psetloc_data->pchLanguage) == _psetloc_data->iPrimaryLen))
427 {
428 // primary language only - test if default LCID
429 if (TestDefaultLanguage(lcid, TRUE, _psetloc_downlevel_data))
430 {
431 // default primary language - set state
432 // also set LCID if not set already
433 _psetloc_downlevel_data->iLcidState |= __LCID_LANGUAGE;
434 if (!_psetloc_downlevel_data->lcidLanguage)
435 _psetloc_downlevel_data->lcidLanguage = lcid;
436 }
437 }
438 else
439 {
440 // language with sublanguage - set state
441 // also set LCID if not set already
442 _psetloc_downlevel_data->iLcidState |= __LCID_LANGUAGE;
443 if (!_psetloc_downlevel_data->lcidLanguage)
444 _psetloc_downlevel_data->lcidLanguage = lcid;
445 }
446 }
447 else if (!_psetloc_data->bAbbrevLanguage && _psetloc_data->iPrimaryLen
448 && !_wcsicmp(_psetloc_data->pchLanguage, rgcInfo))
449 {
450 // primary language match - test for default language only
451 if (TestDefaultLanguage(lcid, FALSE, _psetloc_downlevel_data))
452 {
453 // default primary language - set state
454 // also set LCID if not set already
455 _psetloc_downlevel_data->iLcidState |= __LCID_LANGUAGE;
456 if (!_psetloc_downlevel_data->lcidLanguage)
457 _psetloc_downlevel_data->lcidLanguage = lcid;
458 }
459 }
460 }
461
462 // if LOCALE_FULL set, return FALSE to stop enumeration,
463 // else return TRUE to continue
464 return (_psetloc_downlevel_data->iLcidState & __LCID_FULL) == 0;
465}
static BOOL TestDefaultLanguage(LCID lcid, BOOL bTestPrimary, __crt_qualified_locale_data_downlevel *_psetloc_downlevel_data)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define LOCALE_SABBREVLANGNAME
Definition: winnls.h:29

Referenced by GetLcidFromLangCountry().

◆ LanguageEnumProc()

static BOOL CALLBACK LanguageEnumProc ( _In_z_ PWSTR  lpLcidString)
static

Definition at line 523 of file getqloc_downlevel.cpp.

524{
527
528 LCID lcid = LcidFromHexString(lpLcidString);
529 wchar_t rgcInfo[120];
530
531 // test locale for language specified
532 if (GetLocaleInfoW(lcid, _psetloc_data->bAbbrevLanguage ? LOCALE_SABBREVLANGNAME
534 rgcInfo, _countof(rgcInfo)) == 0)
535 {
536 // set error condition and exit
537 _psetloc_downlevel_data->iLcidState = 0;
538 return TRUE;
539 }
540
541 if (!_wcsicmp(_psetloc_data->pchLanguage, rgcInfo))
542 {
543 // language matched - test if locale country is default
544 // or if locale is implied in the language string
545 if (_psetloc_data->bAbbrevLanguage || TestDefaultLanguage(lcid, TRUE, _psetloc_downlevel_data))
546 {
547 // this locale has the default country
548 _psetloc_downlevel_data->lcidLanguage = _psetloc_downlevel_data->lcidCountry = lcid;
549 _psetloc_downlevel_data->iLcidState |= __LCID_FULL;
550 }
551 }
552 else if (!_psetloc_data->bAbbrevLanguage && _psetloc_data->iPrimaryLen
553 && !_wcsicmp(_psetloc_data->pchLanguage, rgcInfo))
554 {
555 // primary language matched - test if locale country is default
556 if (TestDefaultLanguage(lcid, FALSE, _psetloc_downlevel_data))
557 {
558 // this is the default country
559 _psetloc_downlevel_data->lcidLanguage = _psetloc_downlevel_data->lcidCountry = lcid;
560 _psetloc_downlevel_data->iLcidState |= __LCID_FULL;
561 }
562 }
563
564 return (_psetloc_downlevel_data->iLcidState & __LCID_FULL) == 0;
565}

Referenced by GetLcidFromLanguage().

◆ LcidFromHexString()

static LCID LcidFromHexString ( _In_z_ PCWSTR  lpHexString)
static

Definition at line 803 of file getqloc_downlevel.cpp.

804{
805 wchar_t ch;
806 DWORD lcid = 0;
807
808#pragma warning(disable:__WARNING_POTENTIAL_BUFFER_OVERFLOW_NULLTERMINATED) // 26018 This is an idiomatic nul termination check that Prefast doesn't understand.
809 while ((ch = *lpHexString++) != '\0')
810 {
811 if (ch >= 'a' && ch <= 'f')
812 ch += static_cast<wchar_t>('9' + 1 - 'a');
813 else if (ch >= 'A' && ch <= 'F')
814 ch += static_cast<wchar_t>('9' + 1 - 'A');
815 lcid = lcid * 0x10 + ch - '0';
816 }
817
818 return (LCID)lcid;
819}
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by CountryEnumProc(), LangCountryEnumProc(), and LanguageEnumProc().

◆ ProcessCodePage()

static int ProcessCodePage ( LPCWSTR  lpCodePageStr,
__crt_qualified_locale_data_downlevel _psetloc_downlevel_data 
)
static

Definition at line 687 of file getqloc_downlevel.cpp.

688{
689 int iCodePage;
690
691 if (!lpCodePageStr || !*lpCodePageStr || !wcscmp(lpCodePageStr, L"ACP"))
692 {
693 // get ANSI codepage for the country LCID
694 if (GetLocaleInfoW(_psetloc_downlevel_data->lcidCountry, LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
695 (LPWSTR) &iCodePage, sizeof(iCodePage) / sizeof(wchar_t)) == 0)
696 return 0;
697
698 if (iCodePage == 0) // for locales have no assoicated ANSI codepage, e.g. Hindi locale
699 return GetACP();
700 }
701 else if (!wcscmp(lpCodePageStr, L"OCP"))
702 {
703 // get OEM codepage for the country LCID
704 if (GetLocaleInfoW(_psetloc_downlevel_data->lcidCountry, LOCALE_IDEFAULTCODEPAGE | LOCALE_RETURN_NUMBER,
705 (LPWSTR) &iCodePage, sizeof(iCodePage) / sizeof(wchar_t)) == 0)
706 return 0;
707 }
708 else
709 {
710 // convert decimal string to numeric value
711 iCodePage = (int)_wtol(lpCodePageStr);
712 }
713
714 return iCodePage;
715}
UINT WINAPI GetACP(void)
Definition: locale.c:2021
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
_Check_return_ _CRTIMP long __cdecl _wtol(_In_z_ const wchar_t *_Str)
#define L(x)
Definition: ntvdm.h:50
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define LOCALE_IDEFAULTCODEPAGE
Definition: winnls.h:39
#define LOCALE_IDEFAULTANSICODEPAGE
Definition: winnls.h:40
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by __acrt_get_qualified_locale_downlevel().

◆ TestDefaultCountry()

static BOOL TestDefaultCountry ( LCID  lcid)
static

Definition at line 734 of file getqloc_downlevel.cpp.

735{
737 int i;
738
739 for (i = 0; i < _countof(__rglangidNotDefault); i++)
740 {
741 if (langid == __rglangidNotDefault[i])
742 return FALSE;
743 }
744 return TRUE;
745}
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
USHORT LANGID
Definition: mui.h:9
LANGID langid
Definition: msctf.idl:644
#define LANGIDFROMLCID(l)
Definition: nls.h:18

Referenced by CountryEnumProc(), and LangCountryEnumProc().

◆ TestDefaultLanguage()

static BOOL TestDefaultLanguage ( LCID  lcid,
BOOL  bTestPrimary,
__crt_qualified_locale_data_downlevel _psetloc_downlevel_data 
)
static

Definition at line 766 of file getqloc_downlevel.cpp.

767{
768 UNREFERENCED_PARAMETER(_psetloc_downlevel_data); // CRT_REFACTOR TODO
769
770 DWORD dwLanguage;
773
774 if (GetLocaleInfoW(lcidDefault, LOCALE_ILANGUAGE | LOCALE_RETURN_NUMBER,
775 (LPWSTR) &dwLanguage, sizeof(dwLanguage) / sizeof(wchar_t)) == 0)
776 return FALSE;
777
778 if (lcid != dwLanguage)
779 {
780 // test if string contains an implicit sublanguage by
781 // having a character other than upper/lowercase letters.
782 if (bTestPrimary && GetPrimaryLen(_psetloc_data->pchLanguage) == (int)wcslen(_psetloc_data->pchLanguage))
783 return FALSE;
784 }
785 return TRUE;
786}
#define SORT_DEFAULT
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
#define MAKELCID(lgid, srtid)
#define MAKELANGID(p, s)
Definition: nls.h:15
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define LOCALE_ILANGUAGE
Definition: winnls.h:25

Referenced by LangCountryEnumProc(), and LanguageEnumProc().

◆ TranslateName()

static bool TranslateName ( const __crt_locale_string_table lpTable,
int  high,
const wchar_t **  ppchName 
)
static

Definition at line 230 of file getqloc_downlevel.cpp.

234{
235 int low = 0;
236
237 // typical binary search - do until no more to search or match
238 while (low <= high)
239 {
240 int const i = (low + high) / 2;
241 int const cmp = _wcsicmp(*ppchName, lpTable[i].szName);
242
243 if (cmp == 0)
244 {
245 *ppchName = lpTable[i].chAbbrev;
246 return true;
247 }
248 else if (cmp < 0)
249 high = i - 1;
250 else
251 low = i + 1;
252 }
253
254 return false;
255}
#define cmp(status, error)
Definition: error.c:114
static const WCHAR szName[]
Definition: powrprof.c:45

Referenced by __acrt_get_qualified_locale_downlevel().