Locale

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Locale.

Locale* refers to country/region and language settings that you can use to customize your program. Some locale-dependent categories include the display formats for dates and monetary values. For more information, see Locale Categories.

Use the setlocale function to change or query some or all of the current program or thread locale information while using functions without the _l suffix. The functions with the _l suffix will use the locale parameter passed in for their locale information during the execution of that specific function only. To create a locale for use with a function with a _l suffix, use _create_locale. To free this locale, use _free_locale. To get the current locale, use _get_current_locale.

Use _configthreadlocale to control whether each thread has its own locale, or all threads in a program share the same locale. For more information, see Locales and Code Pages.

More secure versions of the functions in the following table are available, indicated by the _s ("secure") suffix. For more information, see Security Features in the CRT.

Locale-Dependent Routines

RoutineUsesetlocale category setting dependence
atof, _atof_l, _wtof, _wtof_lConvert character to floating-point valueLC_NUMERIC
atoi, _atoi_l, _wtoi, _wtoi_lConvert character to integer valueLC_NUMERIC
_atoi64, _atoi64_l, _wtoi64, _wtoi64_lConvert character to 64-bit integer valueLC_NUMERIC
atol, _atol_l, _wtol, _wtol_lConvert character to long valueLC_NUMERIC
_atodbl, _atodbl_l, _atoldbl, _atoldbl_l, _atoflt, _atoflt_lConvert character to double-long valueLC_NUMERIC
is RoutinesTest given integer for particular condition.LC_CTYPE
isleadbyte, _isleadbyte_lTest for lead byteLC_CTYPE
localeconvRead appropriate values for formatting numeric quantitiesLC_MONETARY, LC_NUMERIC
MB_CUR_MAXMaximum length in bytes of any multibyte character in current locale (macro defined in STDLIB.H)LC_CTYPE
_mbccpy, _mbccpy_l,_mbccpy_s, _mbccpy_s_lCopy one multibyte characterLC_CTYPE
_mbclen, mblen, _mblen_lValidate and return number of bytes in multibyte characterLC_CTYPE
strlen, wcslen, _mbslen, _mbslen_l, _mbstrlen, _mbstrlen_lFor multibyte-character strings: validate each character in string; return string lengthLC_CTYPE
mbstowcs, _mbstowcs_l,mbstowcs_s, _mbstowcs_s_lConvert sequence of multibyte characters to corresponding sequence of wide charactersLC_CTYPE
mbtowc, _mbtowc_lConvert multibyte character to corresponding wide characterLC_CTYPE
printf functionsWrite formatted outputLC_NUMERIC (determines radix character output)
scanf functionsRead formatted inputLC_NUMERIC (determines radix character recognition)
setlocale, _wsetlocaleSelect locale for programNot applicable
strcoll, wcscoll, _mbscoll, _strcoll_l, _wcscoll_l, _mbscoll_lCompare characters of two stringsLC_COLLATE
_stricmp, _wcsicmp, _mbsicmp, _stricmp_l, _wcsicmp_l, _mbsicmp_lCompare two strings without regard to caseLC_CTYPE
_stricoll, _wcsicoll, _mbsicoll, _stricoll_l, _wcsicoll_l, _mbsicoll_lCompare characters of two strings (case insensitive)LC_COLLATE
_strncoll, _wcsncoll, _mbsncoll, _strncoll_l, _wcsncoll_l, _mbsncoll_lCompare first n characters of two stringsLC_COLLATE
_strnicmp, _wcsnicmp, _mbsnicmp, _strnicmp_l, _wcsnicmp_l, _mbsnicmp_lCompare characters of two strings without regard to case.LC_CTYPE
_strnicoll, _wcsnicoll, _mbsnicoll, _strnicoll_l, _wcsnicoll_l, _mbsnicoll_lCompare first n characters of two strings (case insensitive)LC_COLLATE
strftime, wcsftime, _strftime_l, _wcsftime_lFormat date and time value according to supplied format argumentLC_TIME
_strlwr, _wcslwr, _mbslwr, _strlwr_l, _wcslwr_l, _mbslwr_l,_strlwr_s, _strlwr_s_l, _mbslwr_s, _mbslwr_s_l, _wcslwr_s, _wcslwr_s_lConvert, in place, each uppercase letter in given string to lowercaseLC_CTYPE
strtod, _strtod_l, wcstod, _wcstod_lConvert character string to double valueLC_NUMERIC (determines radix character recognition)
strtol, wcstol, _strtol_l, _wcstol_lConvert character string to longvalueLC_NUMERIC (determines radix character recognition)
strtoul, _strtoul_l, wcstoul, _wcstoul_lConvert character string to unsigned long valueLC_NUMERIC (determines radix character recognition)
_strupr, _strupr_l, _mbsupr, _mbsupr_l, _wcsupr_l, _wcsupr,_strupr_s, _strupr_s_l, _mbsupr_s, _mbsupr_s_l, _wcsupr_s, _wcsupr_s_lConvert, in place, each lowercase letter in string to uppercaseLC_CTYPE
strxfrm, wcsxfrm, _strxfrm_l, _wcsxfrm_lTransform string into collated form according to localeLC_COLLATE
tolower, _tolower, towlower, _tolower_l, _towlower_l,_mbctolower, _mbctolower_l, _mbctoupper, _mbctoupper_lConvert given character to corresponding lowercase characterLC_CTYPE
toupper, _toupper, towupper, _toupper_l, _towupper_l,_mbctolower, _mbctolower_l, _mbctoupper, _mbctoupper_lConvert given character to corresponding uppercase letterLC_CTYPE
wcstombs, _wcstombs_l,wcstombs_s, _wcstombs_s_lConvert sequence of wide characters to corresponding sequence of multibyte charactersLC_CTYPE
wctomb, _wctomb_l,wctomb_s, _wctomb_s_lConvert wide character to corresponding multibyte characterLC_CTYPE
System_CAPS_ICON_note.jpg Note

For multibyte routines, the multibyte code page must be equivalent to the locale set with setlocale. _setmbcp, with an argument of _MB_CP_LOCALE makes the multibyte code page the same as the setlocale code page.

Internationalization
Run-Time Routines by Category

Show: