ReactOS 0.4.16-dev-1041-g8b6907f
get_qualified_locale.cpp File Reference
#include <corecrt_internal.h>
#include <locale.h>
#include <stdlib.h>
Include dependency graph for get_qualified_locale.cpp:

Go to the source code of this file.

Macros

#define __LOC_DEFAULT   0x1
 
#define __LOC_PRIMARY   0x2
 
#define __LOC_FULL   0x4
 
#define __LOC_LANGUAGE   0x100
 
#define __LOC_EXISTS   0x200
 

Functions

BOOL __cdecl __acrt_get_qualified_locale (const __crt_locale_strings *, UINT *, __crt_locale_strings *)
 
static BOOL TranslateName (const __crt_locale_string_table *, int, const wchar_t **)
 
static void GetLocaleNameFromLangCountry (__crt_qualified_locale_data *_psetloc_data)
 
static BOOL CALLBACK LangCountryEnumProcEx (_In_z_ LPWSTR, DWORD, LPARAM)
 
static void GetLocaleNameFromLanguage (__crt_qualified_locale_data *_psetloc_data)
 
static BOOL CALLBACK LanguageEnumProcEx (_In_z_ LPWSTR, DWORD, LPARAM)
 
static void GetLocaleNameFromDefault (__crt_qualified_locale_data *_psetloc_data)
 
static int ProcessCodePage (LPCWSTR lpCodePageStr, __crt_qualified_locale_data *_psetloc_data)
 
static BOOL TestDefaultCountry (LPCWSTR localeName)
 
static BOOL TestDefaultLanguage (LPCWSTR localeName, BOOL bTestPrimary, __crt_qualified_locale_data *_psetloc_data)
 
static int GetPrimaryLen (LPCWSTR)
 
static BOOL CALLBACK LangCountryEnumProcEx (LPWSTR lpLocaleString, DWORD dwFlags, LPARAM lParam)
 
static BOOL CALLBACK LanguageEnumProcEx (LPWSTR lpLocaleString, DWORD dwFlags, LPARAM lParam)
 

Variables

__crt_locale_string_table const __acrt_rg_language []
 
__crt_locale_string_table const __acrt_rg_country []
 
size_t const __acrt_rg_language_count {_countof(__acrt_rg_language)}
 
size_t const __acrt_rg_country_count {_countof(__acrt_rg_country )}
 

Macro Definition Documentation

◆ __LOC_DEFAULT

#define __LOC_DEFAULT   0x1

Definition at line 19 of file get_qualified_locale.cpp.

◆ __LOC_EXISTS

#define __LOC_EXISTS   0x200

Definition at line 23 of file get_qualified_locale.cpp.

◆ __LOC_FULL

#define __LOC_FULL   0x4

Definition at line 21 of file get_qualified_locale.cpp.

◆ __LOC_LANGUAGE

#define __LOC_LANGUAGE   0x100

Definition at line 22 of file get_qualified_locale.cpp.

◆ __LOC_PRIMARY

#define __LOC_PRIMARY   0x2

Definition at line 20 of file get_qualified_locale.cpp.

Function Documentation

◆ __acrt_get_qualified_locale()

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

Definition at line 170 of file get_qualified_locale.cpp.

171{
172 int iCodePage;
174 _psetloc_data->_cacheLocaleName[0] = L'\x0'; // Initialize to invariant localename
175
176 // initialize pointer to call locale info routine based on operating system
177
178 _psetloc_data->iLocState = 0;
179 _psetloc_data->pchLanguage = lpInStr->szLanguage;
180 _psetloc_data->pchCountry = lpInStr->szCountry;
181
182 // if country defined
183 // convert non-NLS country strings to three-letter abbreviations
184 if (*_psetloc_data->pchCountry)
186 &_psetloc_data->pchCountry);
187
188
189 // if language defined ...
190 if (*_psetloc_data->pchLanguage)
191 {
192 // and country defined
193 if (*_psetloc_data->pchCountry)
194 {
195 // both language and country strings defined
196 // get locale info using language and country
197 GetLocaleNameFromLangCountry(_psetloc_data);
198 }
199 else
200 {
201 // language string defined, but country string undefined
202 // get locale info using language only
203 GetLocaleNameFromLanguage(_psetloc_data);
204 }
205
206 // still not done?
207 if (_psetloc_data->iLocState == 0)
208 {
209 // first attempt failed, try substituting the language name
210 // convert non-NLS language strings to three-letter abbrevs
212 &_psetloc_data->pchLanguage))
213 {
214 if (*_psetloc_data->pchCountry)
215 {
216 // get locale info using language and country
217 GetLocaleNameFromLangCountry(_psetloc_data);
218 }
219 else
220 {
221 // get locale info using language only
222 GetLocaleNameFromLanguage(_psetloc_data);
223 }
224 }
225 }
226 }
227 else
228 {
229 // language is an empty string, use the User Default locale name
230 GetLocaleNameFromDefault(_psetloc_data);
231 }
232
233 // test for error in locale processing
234 if (_psetloc_data->iLocState == 0)
235 return FALSE;
236
237 // process codepage value
238 if (lpInStr == nullptr || *lpInStr->szLanguage || *lpInStr->szCodePage )
239 {
240 // If there's no input, then get the current codepage
241 // If they explicitly chose a language, use that default codepage
242 // If they explicilty set a codepage, then use that
243 iCodePage = ProcessCodePage(lpInStr ? lpInStr->szCodePage : nullptr, _psetloc_data);
244 }
245 else
246 {
247 // No language or codepage means that they want to set to the
248 // user default settings, get that codepage (could be UTF-8)
249 iCodePage = GetACP();
250 }
251
252 // verify codepage validity
253 // CP_UTF7 is unexpected and has never been previously permitted.
254 // CP_UTF8 is the current preferred codepage
255 if (!iCodePage || iCodePage == CP_UTF7 || !IsValidCodePage((WORD)iCodePage))
256 return FALSE;
257
258 // set codepage
259 if (lpOutCodePage)
260 {
261 *lpOutCodePage = (UINT)iCodePage;
262 }
263
264 // set locale name and codepage results
265 if (lpOutStr)
266 {
267 lpOutStr->szLocaleName[0] = L'\x0'; // Init the locale name to empty string
268
269 _ERRCHECK(wcsncpy_s(lpOutStr->szLocaleName, _countof(lpOutStr->szLocaleName), _psetloc_data->_cacheLocaleName, wcslen(_psetloc_data->_cacheLocaleName) + 1));
270
271 // Get and store the English language lang name, to be returned to user
273 lpOutStr->szLanguage, MAX_LANG_LEN) == 0)
274 return FALSE;
275
276 // Get and store the English language country name, to be returned to user
278 lpOutStr->szCountry, MAX_CTRY_LEN) == 0)
279 return FALSE;
280
281 // Special case: Both '.' and '_' are separators in string passed to setlocale,
282 // so if found in Country we use abbreviated name instead.
283 if (wcschr(lpOutStr->szCountry, L'_') || wcschr(lpOutStr->szCountry, L'.'))
285 lpOutStr->szCountry, MAX_CTRY_LEN) == 0)
286 return FALSE;
287
288 if (iCodePage == CP_UTF8)
289 {
290 // We want UTF-8 to look like utf8, not 65001
291 _ERRCHECK(wcsncpy_s(lpOutStr->szCodePage, _countof(lpOutStr->szCodePage), L"utf8", 5));
292 }
293 else
294 {
295 _itow_s((int)iCodePage, (wchar_t *)lpOutStr->szCodePage, MAX_CP_LEN, 10);
296 }
297 }
298
299 return TRUE;
300}
#define MAX_LANG_LEN
#define MAX_CP_LEN
#define MAX_CTRY_LEN
__acrt_ptd *__cdecl __acrt_getptd(void)
int WINAPI __acrt_GetLocaleInfoEx(_In_opt_ LPCWSTR locale_name, _In_ LCTYPE lc_type, _Out_writes_opt_(data_count) LPWSTR data, _In_ int data_count)
#define _ERRCHECK(e)
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define wcschr
Definition: compat.h:17
UINT WINAPI GetACP(void)
Definition: locale.c:2021
BOOL WINAPI IsValidCodePage(UINT codepage)
Definition: locale.c:2079
unsigned short WORD
Definition: ntddk_ex.h:93
static BOOL TranslateName(const __crt_locale_string_table *, int, const wchar_t **)
__crt_locale_string_table const __acrt_rg_language[]
static void GetLocaleNameFromLanguage(__crt_qualified_locale_data *_psetloc_data)
__crt_locale_string_table const __acrt_rg_country[]
static int ProcessCodePage(LPCWSTR lpCodePageStr, __crt_qualified_locale_data *_psetloc_data)
static void GetLocaleNameFromLangCountry(__crt_qualified_locale_data *_psetloc_data)
static void GetLocaleNameFromDefault(__crt_qualified_locale_data *_psetloc_data)
size_t const __acrt_rg_language_count
size_t const __acrt_rg_country_count
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
int CDECL _itow_s(int value, wchar_t *str, size_t size, int radix)
Definition: itow.c:222
#define wcsncpy_s(d, l, s, n)
Definition: utility.h:202
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
#define CP_UTF8
Definition: nls.h:20
#define _countof(array)
Definition: sndvol32.h:70
__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 CP_UTF7
Definition: winnls.h:237
#define LOCALE_SENGLISHLANGUAGENAME
Definition: winnls.h:28
#define LOCALE_SABBREVCTRYNAME
Definition: winnls.h:35
#define LOCALE_SENGLISHCOUNTRYNAME
Definition: winnls.h:34

Referenced by _expandlocale().

◆ GetLocaleNameFromDefault()

static void GetLocaleNameFromDefault ( __crt_qualified_locale_data _psetloc_data)
static

Definition at line 669 of file get_qualified_locale.cpp.

670{
671 wchar_t localeName[LOCALE_NAME_MAX_LENGTH];
672 _psetloc_data->iLocState |= (__LOC_FULL | __LOC_LANGUAGE);
673
674 // Store the default user locale name. The returned buffer size includes the
675 // terminating null character, so only store if the size returned is > 1
677 {
678 _ERRCHECK(wcsncpy_s(_psetloc_data->_cacheLocaleName, _countof(_psetloc_data->_cacheLocaleName), localeName, wcslen(localeName) + 1));
679 }
680}
int WINAPI __acrt_GetUserDefaultLocaleName(_Out_writes_(locale_name_count) LPWSTR locale_name, _In_ int locale_name_count)
#define __LOC_FULL
#define __LOC_LANGUAGE
#define LOCALE_NAME_MAX_LENGTH

Referenced by __acrt_get_qualified_locale().

◆ GetLocaleNameFromLangCountry()

static void GetLocaleNameFromLangCountry ( __crt_qualified_locale_data _psetloc_data)
static

Definition at line 381 of file get_qualified_locale.cpp.

382{
383 // initialize static variables for callback use
384 _psetloc_data->bAbbrevLanguage = wcslen(_psetloc_data->pchLanguage) == 3;
385 _psetloc_data->bAbbrevCountry = wcslen(_psetloc_data->pchCountry) == 3;
386
387 _psetloc_data->iPrimaryLen = _psetloc_data->bAbbrevLanguage ?
388 2 : GetPrimaryLen(_psetloc_data->pchLanguage);
389
390 // Enumerate all locales that come with the operating system,
391 // including replacement locales, but excluding alternate sorts.
393
394 // locale value is invalid if the language was not installed or the language
395 // was not available for the country specified
396 if (!(_psetloc_data->iLocState & __LOC_LANGUAGE) ||
397 !(_psetloc_data->iLocState & __LOC_EXISTS) ||
398 !(_psetloc_data->iLocState & (__LOC_FULL |
401 _psetloc_data->iLocState = 0;
402}
BOOL WINAPI __acrt_EnumSystemLocalesEx(_In_ LOCALE_ENUMPROCEX enum_proc, _In_ DWORD flags, _In_ LPARAM param, _In_opt_ LPVOID reserved)
static int GetPrimaryLen(LPCWSTR)
#define __LOC_PRIMARY
#define __LOC_DEFAULT
static BOOL CALLBACK LangCountryEnumProcEx(_In_z_ LPWSTR, DWORD, LPARAM)
#define __LOC_EXISTS
#define LOCALE_SUPPLEMENTAL
Definition: winnls.h:209
#define LOCALE_WINDOWS
Definition: winnls.h:208

Referenced by __acrt_get_qualified_locale().

◆ GetLocaleNameFromLanguage()

static void GetLocaleNameFromLanguage ( __crt_qualified_locale_data _psetloc_data)
static

Definition at line 592 of file get_qualified_locale.cpp.

593{
594 // initialize static variables for callback use
595 _psetloc_data->bAbbrevLanguage = wcslen(_psetloc_data->pchLanguage) == 3;
596 _psetloc_data->iPrimaryLen = _psetloc_data->bAbbrevLanguage ? 2 : GetPrimaryLen(_psetloc_data->pchLanguage);
597
598 // Enumerate all locales that come with the operating system, including replacement locales,
599 // but excluding alternate sorts.
601
602 // locale value is invalid if the language was not installed
603 // or the language was not available for the country specified
604 if ((_psetloc_data->iLocState & __LOC_FULL) == 0)
605 _psetloc_data->iLocState = 0;
606}
static BOOL CALLBACK LanguageEnumProcEx(_In_z_ LPWSTR, DWORD, LPARAM)

Referenced by __acrt_get_qualified_locale().

◆ GetPrimaryLen()

static int GetPrimaryLen ( LPCWSTR  pchLanguage)
static

Definition at line 831 of file get_qualified_locale.cpp.

832{
833 int len = 0;
834 wchar_t ch;
835
836 if (!pchLanguage)
837 return 0;
838
839 ch = *pchLanguage++;
840 while ((ch >= L'A' && ch <= L'Z') || (ch >= L'a' && ch <= L'z'))
841 {
842 len++;
843 ch = *pchLanguage++;
844 }
845
846 return len;
847}
GLenum GLsizei len
Definition: glext.h:6722

Referenced by GetLocaleNameFromLangCountry(), GetLocaleNameFromLanguage(), and TestDefaultLanguage().

◆ LangCountryEnumProcEx() [1/2]

static BOOL CALLBACK LangCountryEnumProcEx ( _In_z_  LPWSTR,
DWORD  ,
LPARAM   
)
static

◆ LangCountryEnumProcEx() [2/2]

static BOOL CALLBACK LangCountryEnumProcEx ( LPWSTR  lpLocaleString,
DWORD  dwFlags,
LPARAM  lParam 
)
static

Definition at line 431 of file get_qualified_locale.cpp.

432{
435
437 wchar_t rgcInfo[MAX_LANG_LEN]; // MAX_LANG_LEN == MAX_CTRY_LEN == 64
438
439 // test locale country against input value
440 if (__acrt_GetLocaleInfoEx(lpLocaleString,
442 rgcInfo, _countof(rgcInfo)) == 0)
443 {
444 // set error condition and exit
445 _psetloc_data->iLocState = 0;
446 return TRUE;
447 }
448
449 // if country names matched
450 if (_wcsicmp(_psetloc_data->pchCountry, rgcInfo) == 0)
451 {
452 // test for language match
453 if (__acrt_GetLocaleInfoEx(lpLocaleString,
454 _psetloc_data->bAbbrevLanguage ?
456 rgcInfo, _countof(rgcInfo)) == 0)
457 {
458 // set error condition and exit
459 _psetloc_data->iLocState = 0;
460 return TRUE;
461 }
462
463 if (_wcsicmp(_psetloc_data->pchLanguage, rgcInfo) == 0)
464 {
465 // language matched also - set state and value
466 // this is the best match
467 _psetloc_data->iLocState |= (__LOC_FULL |
470
471 _ERRCHECK(wcsncpy_s(_psetloc_data->_cacheLocaleName, _countof(_psetloc_data->_cacheLocaleName), lpLocaleString, wcslen(lpLocaleString) + 1));
472 }
473 // test if match already for primary langauage
474 else if (!(_psetloc_data->iLocState & __LOC_PRIMARY))
475 {
476 // if not, use _psetloc_data->iPrimaryLen to partial match language string
477 if (_psetloc_data->iPrimaryLen && !_wcsnicmp(_psetloc_data->pchLanguage, rgcInfo, _psetloc_data->iPrimaryLen))
478 {
479 // primary language matched - set locale name
480 _psetloc_data->iLocState |= __LOC_PRIMARY;
481 _ERRCHECK(wcsncpy_s(_psetloc_data->_cacheLocaleName, _countof(_psetloc_data->_cacheLocaleName), lpLocaleString, wcslen(lpLocaleString) + 1));
482 }
483
484 // test if default language already defined
485 else if (!(_psetloc_data->iLocState & __LOC_DEFAULT))
486 {
487 // if not, test if locale language is default for country
488 if (TestDefaultCountry(lpLocaleString))
489 {
490 // default language for country - set state, value
491 _psetloc_data->iLocState |= __LOC_DEFAULT;
492 _ERRCHECK(wcsncpy_s(_psetloc_data->_cacheLocaleName, _countof(_psetloc_data->_cacheLocaleName), lpLocaleString, wcslen(lpLocaleString) + 1));
493 }
494 }
495 }
496 }
497
498 // test if input language both exists and default primary language defined
499 if ((_psetloc_data->iLocState & (__LOC_LANGUAGE | __LOC_EXISTS)) !=
501 {
502 // test language match to determine whether it is installed
503 if (__acrt_GetLocaleInfoEx(lpLocaleString, _psetloc_data->bAbbrevLanguage ? LOCALE_SABBREVLANGNAME
505 rgcInfo, _countof(rgcInfo)) == 0)
506 {
507 // set error condition and exit
508 _psetloc_data->iLocState = 0;
509 return TRUE;
510 }
511
512 // the input language matches
513 if (_wcsicmp(_psetloc_data->pchLanguage, rgcInfo) == 0)
514 {
515 // language matched - set bit for existance
516 _psetloc_data->iLocState |= __LOC_EXISTS;
517
518 if (_psetloc_data->bAbbrevLanguage)
519 {
520 // abbreviation - set state
521 // also set language locale name if not set already
522 _psetloc_data->iLocState |= __LOC_LANGUAGE;
523 if (!_psetloc_data->_cacheLocaleName[0])
524 _ERRCHECK(wcsncpy_s(_psetloc_data->_cacheLocaleName, _countof(_psetloc_data->_cacheLocaleName), lpLocaleString, wcslen(lpLocaleString) + 1));
525 }
526
527 // test if language is primary only (no sublanguage)
528 else if (_psetloc_data->iPrimaryLen && ((int)wcslen(_psetloc_data->pchLanguage) == _psetloc_data->iPrimaryLen))
529 {
530 // primary language only - test if default locale name
531 if (TestDefaultLanguage(lpLocaleString, TRUE, _psetloc_data))
532 {
533 // default primary language - set state
534 // also set locale name if not set already
535 _psetloc_data->iLocState |= __LOC_LANGUAGE;
536 if (!_psetloc_data->_cacheLocaleName[0])
537 _ERRCHECK(wcsncpy_s(_psetloc_data->_cacheLocaleName, _countof(_psetloc_data->_cacheLocaleName), lpLocaleString, wcslen(lpLocaleString) + 1));
538 }
539 }
540 else
541 {
542 // language with sublanguage - set state
543 // also set locale name if not set already
544 _psetloc_data->iLocState |= __LOC_LANGUAGE;
545 if (!_psetloc_data->_cacheLocaleName[0])
546 _ERRCHECK(wcsncpy_s(_psetloc_data->_cacheLocaleName, _countof(_psetloc_data->_cacheLocaleName), lpLocaleString, wcslen(lpLocaleString) + 1));
547 }
548 }
549 }
550
551 // if LOCALE_FULL set, return FALSE to stop enumeration,
552 // else return TRUE to continue
553 return (_psetloc_data->iLocState & __LOC_FULL) == 0;
554}
LPARAM lParam
Definition: combotst.c:139
static BOOL TestDefaultLanguage(LPCWSTR localeName, BOOL bTestPrimary, __crt_qualified_locale_data *_psetloc_data)
static BOOL TestDefaultCountry(LPCWSTR localeName)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_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)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define LOCALE_SABBREVLANGNAME
Definition: winnls.h:29

◆ LanguageEnumProcEx() [1/2]

static BOOL CALLBACK LanguageEnumProcEx ( _In_z_  LPWSTR,
DWORD  ,
LPARAM   
)
static

◆ LanguageEnumProcEx() [2/2]

static BOOL CALLBACK LanguageEnumProcEx ( LPWSTR  lpLocaleString,
DWORD  dwFlags,
LPARAM  lParam 
)
static

Definition at line 627 of file get_qualified_locale.cpp.

628{
631
633 wchar_t rgcInfo[120];
634
635 // test locale for language specified
636 if (__acrt_GetLocaleInfoEx(lpLocaleString, _psetloc_data->bAbbrevLanguage ? LOCALE_SABBREVLANGNAME
638 rgcInfo, _countof(rgcInfo)) == 0)
639 {
640 // set error condition and exit
641 _psetloc_data->iLocState = 0;
642 return TRUE;
643 }
644
645 if (_wcsicmp(_psetloc_data->pchLanguage, rgcInfo) == 0)
646 {
647 // language matches
648 _ERRCHECK(wcsncpy_s(_psetloc_data->_cacheLocaleName, _countof(_psetloc_data->_cacheLocaleName), lpLocaleString, wcslen(lpLocaleString) + 1));
649
650 _psetloc_data->iLocState |= __LOC_FULL;
651 }
652
653 return (_psetloc_data->iLocState & __LOC_FULL) == 0;
654}

◆ ProcessCodePage()

static int ProcessCodePage ( LPCWSTR  lpCodePageStr,
__crt_qualified_locale_data _psetloc_data 
)
static

Definition at line 700 of file get_qualified_locale.cpp.

701{
702 int iCodePage;
703
704 if (!lpCodePageStr || !*lpCodePageStr || wcscmp(lpCodePageStr, L"ACP") == 0)
705 {
706 // get ANSI codepage for the country locale name
707 // CONSIDER: If system is running UTF-8 ACP, then always return UTF-8?
708 if (__acrt_GetLocaleInfoEx(_psetloc_data->_cacheLocaleName, LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
709 (LPWSTR) &iCodePage, sizeof(iCodePage) / sizeof(wchar_t)) == 0)
710 return 0;
711
712 // Locales with no code page ("Unicode only locales") should return UTF-8
713 // (0, 1 & 2 are Unicode-Only ACP, OEMCP & MacCP flags)
714 if (iCodePage < 3)
715 {
716 return CP_UTF8;
717 }
718
719 }
720 else if (_wcsicmp(lpCodePageStr, L"utf8") == 0 ||
721 _wcsicmp(lpCodePageStr, L"utf-8") == 0)
722 {
723 // Use UTF-8
724 return CP_UTF8;
725 }
726 else if (wcscmp(lpCodePageStr, L"OCP") == 0)
727 {
728 // get OEM codepage for the country locale name
729 // CONSIDER: If system is running UTF-8 ACP, then always return UTF-8?
730 if (__acrt_GetLocaleInfoEx(_psetloc_data->_cacheLocaleName, LOCALE_IDEFAULTCODEPAGE | LOCALE_RETURN_NUMBER,
731 (LPWSTR) &iCodePage, sizeof(iCodePage) / sizeof(wchar_t)) == 0)
732 return 0;
733
734 // Locales with no code page ("unicode only locales") should return UTF-8
735 // (0, 1 & 2 are Unicode-Only ACP, OEMCP & MacCP flags)
736 if (iCodePage < 3)
737 {
738 return CP_UTF8;
739 }
740 }
741 else
742 {
743 // convert decimal string to numeric value
744 iCodePage = (int)_wtol(lpCodePageStr);
745 }
746
747 return iCodePage;
748}
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)
_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().

◆ TestDefaultCountry()

static BOOL TestDefaultCountry ( LPCWSTR  localeName)
static

Definition at line 766 of file get_qualified_locale.cpp.

767{
768 wchar_t sIso639LangName[9]; // The maximum length for LOCALE_SISO3166CTRYNAME
769 // is 9 including nullptr
770
771 // Get 2-letter ISO Standard 639 or 3-letter ISO 639-2 value
773 sIso639LangName, _countof(sIso639LangName)) == 0)
774 return FALSE;
775
776 // Determine if this is a neutral language
777 if (wcsncmp(sIso639LangName, localeName, _countof(sIso639LangName)) == 0)
778 return TRUE;
779
780 return FALSE;
781}
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define LOCALE_SISO639LANGNAME
Definition: winnls.h:128

Referenced by LangCountryEnumProcEx(), and TestDefaultLanguage().

◆ TestDefaultLanguage()

static BOOL TestDefaultLanguage ( LPCWSTR  localeName,
BOOL  bTestPrimary,
__crt_qualified_locale_data _psetloc_data 
)
static

Definition at line 802 of file get_qualified_locale.cpp.

803{
804 if (!TestDefaultCountry (localeName))
805 {
806 // test if string contains an implicit sublanguage by
807 // having a character other than upper/lowercase letters.
808 if (bTestPrimary && GetPrimaryLen(_psetloc_data->pchLanguage) == (int)wcslen(_psetloc_data->pchLanguage))
809 return FALSE;
810 }
811
812 return TRUE;
813}

Referenced by LangCountryEnumProcEx().

◆ TranslateName()

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

Definition at line 320 of file get_qualified_locale.cpp.

324{
325 int i;
326 int cmp = 1;
327 int low = 0;
328
329 // typical binary search - do until no more to search or match
330 while (low <= high && cmp != 0)
331 {
332 i = (low + high) / 2;
333 cmp = _wcsicmp(*ppchName, (const wchar_t *)(*(lpTable + i)).szName);
334
335 if (cmp == 0)
336 *ppchName = (*(lpTable + i)).chAbbrev;
337 else if (cmp < 0)
338 high = i - 1;
339 else
340 low = i + 1;
341 }
342
343 return !cmp;
344}
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
#define cmp(status, error)
Definition: error.c:114
static const WCHAR szName[]
Definition: powrprof.c:45

Referenced by __acrt_get_qualified_locale().

Variable Documentation

◆ __acrt_rg_country

__crt_locale_string_table const __acrt_rg_country[]
extern
Initial value:
{
{ L"america", L"USA" },
{ L"britain", L"GBR" },
{ L"china", L"CHN" },
{ L"czech", L"CZE" },
{ L"england", L"GBR" },
{ L"great britain", L"GBR" },
{ L"holland", L"NLD" },
{ L"hong-kong", L"HKG" },
{ L"new-zealand", L"NZL" },
{ L"nz", L"NZL" },
{ L"pr china", L"CHN" },
{ L"pr-china", L"CHN" },
{ L"puerto-rico", L"PRI" },
{ L"slovak", L"SVK" },
{ L"south africa", L"ZAF" },
{ L"south korea", L"KOR" },
{ L"south-africa", L"ZAF" },
{ L"south-korea", L"KOR" },
{ L"trinidad & tobago", L"TTO" },
{ L"uk", L"GBR" },
{ L"united-kingdom", L"GBR" },
{ L"united-states", L"USA" },
{ L"us", L"USA" },
}

Referenced by __acrt_get_qualified_locale().

◆ __acrt_rg_country_count

size_t const __acrt_rg_country_count {_countof(__acrt_rg_country )}
extern

◆ __acrt_rg_language

__crt_locale_string_table const __acrt_rg_language[]
extern

◆ __acrt_rg_language_count

size_t const __acrt_rg_language_count {_countof(__acrt_rg_language)}
extern