xlocale

Thread-safe extended locale support -- Thread-safe extended locale support 

Thread-safe extended locale support


LIBRARY

Standard C Library (c.lib, -lc)


SYNOPSIS

#include <locale.h>


DESCRIPTION

The extended locale support includes a set of functions for setting thread-local locales, as well convenience functions for performing locale-aware calls with a specified locale.

The core of the xlocale API is the locale_t type. This is an opaque type encapsulating a locale. Instances of this can be either set as the locale for a specific thread or passed directly to the _l suffixed variants of various standard C functions. Two special locale_t values are available:

The global locale is the locale set with the setlocale() function.

Standards Conformance

The functions conform to IEEE Std 1003.1-2008


CAVEATS

The setlocale() function, and others in the family, refer to the global locale. Other functions that depend on the locale, however, will take the thread-local locale if one has been set. This means that the idiom of setting the locale using setlocale(), calling a locale-dependent function, and then restoring the locale will not have the expected behavior if the current thread has had a locale set using uselocale(). You should avoid this idiom and prefer to use the _l suffixed versions instead.

The NuTCRACKER Platform extends the use of current (function, thread, or global) ctype locale to treat file names as multi-byte characters and map them to UNICODE in functions like open(), and mkdir(). Further it treats data written to the console as multi-byte and converts them to UNICODE for console output. If this behavior is undesirable, it can be reverted to previous NuTCRACKER Platform behaviour by setting NUT_ANSI_LOCALE in the environment before launching the ported application or calling _NutConf()(_NC_SET_ANSI_LOCALE, 1) before calling a POSIX API.


SEE ALSO

Functions:
duplocale(), freelocale(), localeconv(), newlocale(), querylocale(), uselocale()

PTC MKS Toolkit UNIX to Windows Porting Guide


CONVENIENCE FUNCTIONS

The xlocale API includes a number of _l suffixed convenience functions. These are variants of standard C functions that have been modified to take an explicit locale_t parameter as the final argument or, in the case of variadic functions, as an additional argument directly before the format string. Each of these functions accepts either NULL or LC_GLOBAL_LOCALE. In these functions, NULL refers to the C locale, rather than the thread's current locale. If you wish to use the thread's current locale, then use the unsuffixed version of the function.

These functions are exposed by including <locale.h> after including the relevant headers for the standard variant. For example, the strtol_l() function is exposed by including <xlocale.h> after <stdlib.h>, which defines strtol().

For reference, a complete list of the locale-aware functions that are available in this form, along with the headers that expose them, is provided here:

<wctype.h>  

iswalnum_l(), iswalpha_l(), iswcntrl_l(), iswctype_l(), iswdigit_l(), iswgraph_l(), iswlower_l(), iswprint_l(), iswpunct_l(), iswspace_l(), iswupper_l(), iswxdigit_l(), towlower_l(), towupper_l(), wctype_l(),

<ctype.h>  

digittoint_l(), isalnum_l(), isalpha_l(), isblank_l(), iscntrl_l(), isdigit_l(), isgraph_l(), ishexnumber_l(), isideogram_l(), islower_l(), isnumber_l(), isphonogram_l(), isprint_l(), ispunct_l(), isrune_l(), isspace_l(), isspecial_l(), isupper_l(), isxdigit_l(), tolower_l(), toupper_l()

<inttypes.h>  

strtoimax_l(), strtoumax_l(), wcstoimax_l(), wcstoumax_l()

<langinfo.h>  

nl_langinfo_l()

<stdio.h>  

asprintf_l(), fprintf_l(), fscanf_l(), printf_l(), scanf_l(), snprintf_l(), sprintf_l(), sscanf_l(), vasprintf_l(), vfprintf_l(), vfscanf_l(), vprintf_l(), vscanf_l(), vsnprintf_l(), vsprintf_l(), vsscanf_l()

<stdlib.h>  

atof_l(), atoi_l(), atol_l(), atoll_l(), mblen_l(), mbstowcs_l(), mbtowc_l(), strtod_l(), strtof_l(), strtol_l(), strtold_l(), strtoll_l(), strtoq_l(), strtoul_l(), strtoull_l(), strtouq_l(), wcstombs_l(), wctomb_l()

<string.h>  

strcoll_l(), strxfrm_l(), strcasecmp_l(), strcasestr_l(), strncasecmp_l()

<time.h>  

strftime_l() strptime_l()

<wchar.h>  

btowc_l(), fgetwc_l(), fgetws_l(), fputwc_l(), fputws_l(), fwprintf_l(), fwscanf_l(), getwc_l(), getwchar_l(), mbrlen_l(), mbrtowc_l(), mbsinit_l(), mbsnrtowcs_l(), mbsrtowcs_l(), putwc_l(), putwchar_l(), swprintf_l(), swscanf_l(), ungetwc_l(), vfwprintf_l(), vfwscanf_l(), vswprintf_l(), vswscanf_l(), vwprintf_l(), vwscanf_l(), wcrtomb_l(), wcscoll_l(), wcsftime_l(), wcsnrtombs_l(), wcsrtombs_l(), wcstod_l(), wcstof_l(), wcstol_l(), wcstold_l(), wcstoll_l(), wcstoul_l(), wcstoull_l(), wcswidth_l(), wcsxfrm_l(), wctob_l(), wcwidth_l(), wprintf_l(), wscanf_l()

<wctype.h>  

iswblank_l(), iswhexnumber_l(), iswideogram_l(), iswnumber_l(), iswphonogram_l(), iswrune_l(), iswspecial_l(), nextwctype_l(), towctrans_l(), wctrans_l()

<xlocale.h>  

localeconv_l()


PTC MKS Toolkit 10.3 Documentation Build 39.