xlocale.3   [plain text]


.Dd March 11, 2005
.Dt XLOCALE 3
.Os
.Sh NAME
.Nm xlocale
.Nd Extended locale support.
.Sh LIBRARY
.Lb libc
.Sh DESCRIPTION
Include
.Aq xlocale.h
for extended locale support.
It can be used alone or with the POSIX locale API in
.Aq locale.h .
.Pp
The extended locale, or "xlocale" API consists of five basic routines,
which are documented separately:
.Xr duplocale 3 ,
.Xr freelocale 3 ,
.Xr newlocale 3 ,
.Xr querylocale 3 ,
and
.Xr uselocale 3 .
For each of these routines, if a NULL
.Vt locale_t
is given, the current locale is used.
.Pp
In addition,
.Aq xlocale.h
defines a few macros:
.Pp
.Bl -dash
.It
LC_GLOBAL_LOCALE - A special
.Vt locale_t
value that corresponds to the global, process-wide locale.
.It
MB_CUR_MAX - This macro is traditionally defined as an integer
containing the value of the longest multi-byte string
that a single-wide character in the global locale can translate into.
With extended locales, this macro is replaced with a function
that returns the value of the longest multi-byte string
that a single-wide character in the current locale (per-thread or global)
can translate into.
.It
MB_CUR_MAX_L(loc) - This macro is equivalent to MB_CUR_MAX,
except that it may be passed a specific locale directly.
.El
.Sh CAVEATS
The POSIX
.Xr setlocale 3
function only affects the global locale,
so using it when a per-thread locale is in effect
will not change locale behavior for that thread.
However, it will change behavior for threads
with no per-thread locale in effect.
#ifdef UNIFDEF_LEGACY_RUNE_APIS
.Pp
The routines defined in
.Aq rune.h
are deprecated, and may not be fully consistent with the xlocale API.
Of particular note is
.Fn setinvalidrune ,
which would normally modify the value in the global locale.
Since this value resides in a sub-structure of
.Vt locale_t
and sub-structures may be shared by multiple locales,
.Fn setinvalidrune
has been modified to make a copy of the sub-structure.
This prevents it from affecting other locales.
#endif /* UNIFDEF_LEGACY_RUNE_APIS */
.Sh SEE ALSO
.Xr duplocale 3 ,
.Xr freelocale 3 ,
.Xr localeconv 3 ,
.Xr newlocale 3 ,
.Xr querylocale 3 ,
.Xr uselocale 3
.Sh CONVENIENCE FUNCTIONS
The xlocale API also includes "convenience functions":
functions that can be executed using a given locale,
rather than the current locale.
These functions all take one extra
.Vt locale_t
argument at the end of the traditional argument list,
except in the case of variable-argument functions,
in which case the extra argument comes before the format string.
If a NULL
.Vt locale_t
is passed, the C locale will be used.
.Pp
For completeness,
the convenience functions are listed here
(organized by the header file that contains the original function).
.Pp
.Bl -tag -width monetary.h
.It Aq _wctype.h
.Xr iswalnum_l 3 ,
.Xr iswalpha_l 3 ,
.Xr iswcntrl_l 3 ,
.Xr iswctype_l 3 ,
.Xr iswdigit_l 3 ,
.Xr iswgraph_l 3 ,
.Xr iswlower_l 3 ,
.Xr iswprint_l 3 ,
.Xr iswpunct_l 3 ,
.Xr iswspace_l 3 ,
.Xr iswupper_l 3 ,
.Xr iswxdigit_l 3 ,
.Xr towlower_l 3 ,
.Xr towupper_l 3 ,
.Xr wctype_l 3
.It Aq ctype.h
.Xr digittoint_l 3 ,
.Xr isalnum_l 3 ,
.Xr isalpha_l 3 ,
.Xr isblank_l 3 ,
.Xr iscntrl_l 3 ,
.Xr isdigit_l 3 ,
.Xr isgraph_l 3 ,
.Xr ishexnumber_l 3 ,
.Xr isideogram_l 3 ,
.Xr islower_l 3 ,
.Xr isnumber_l 3 ,
.Xr isphonogram_l 3 ,
.Xr isprint_l 3 ,
.Xr ispunct_l 3 ,
.Xr isrune_l 3 ,
.Xr isspace_l 3 ,
.Xr isspecial_l 3 ,
.Xr isupper_l 3 ,
.Xr isxdigit_l 3 ,
.Xr tolower_l 3 ,
.Xr toupper_l 3
.It Aq inttypes.h
.Xr strtoimax_l 3 ,
.Xr strtoumax_l 3 ,
.Xr wcstoimax_l 3 ,
.Xr wcstoumax_l 3
.It Aq langinfo.h
.Xr nl_langinfo_l 3
.It Aq monetary.h
.Xr strfmon_l 3
.It Aq stdio.h
.Xr asprintf_l 3 ,
.Xr fprintf_l 3 ,
.Xr fscanf_l 3 ,
.Xr printf_l 3 ,
.Xr scanf_l 3 ,
.Xr snprintf_l 3 ,
.Xr sprintf_l 3 ,
.Xr sscanf_l 3 ,
.Xr vasprintf_l 3 ,
.Xr vfprintf_l 3 ,
.Xr vfscanf_l 3 ,
.Xr vprintf_l 3 ,
.Xr vscanf_l 3 ,
.Xr vsnprintf_l 3 ,
.Xr vsprintf_l 3 ,
.Xr vsscanf_l 3
.It Aq stdlib.h
.Xr atof_l 3 ,
.Xr atoi_l 3 ,
.Xr atol_l 3 ,
.Xr atoll_l 3 ,
.Xr mblen_l 3 ,
.Xr mbstowcs_l 3 ,
.Xr mbtowc_l 3 ,
.Xr strtod_l 3 ,
.Xr strtof_l 3 ,
.Xr strtol_l 3 ,
.Xr strtold_l 3 ,
.Xr strtoll_l 3 ,
.Xr strtoq_l 3 ,
.Xr strtoul_l 3 ,
.Xr strtoull_l 3 ,
.Xr strtouq_l 3 ,
.Xr wcstombs_l 3 ,
.Xr wctomb_l 3
.It Aq string.h
.Xr strcoll_l 3 ,
.Xr strxfrm_l 3 ,
.Xr strcasecmp_l 3 ,
.Xr strcasestr_l 3 ,
.Xr strncasecmp_l 3
.It Aq time.h
.Xr strftime_l 3 ,
.Xr strptime_l 3
.It Aq wchar.h
.Xr btowc_l 3 ,
.Xr fgetwc_l 3 ,
.Xr *fgetws_l 3 ,
.Xr fputwc_l 3 ,
.Xr fputws_l 3 ,
.Xr fwprintf_l 3 ,
.Xr fwscanf_l 3 ,
.Xr getwc_l 3 ,
.Xr getwchar_l 3 ,
.Xr mbrlen_l 3 ,
.Xr mbrtowc_l 3 ,
.Xr mbsinit_l 3 ,
.Xr mbsnrtowcs_l 3 ,
.Xr mbsrtowcs_l 3 ,
.Xr putwc_l 3 ,
.Xr putwchar_l 3 ,
.Xr swprintf_l 3 ,
.Xr swscanf_l 3 ,
.Xr ungetwc_l 3 ,
.Xr vfwprintf_l 3 ,
.Xr vfwscanf_l 3 ,
.Xr vswprintf_l 3 ,
.Xr vswscanf_l 3 ,
.Xr vwprintf_l 3 ,
.Xr vwscanf_l 3 ,
.Xr wcrtomb_l 3 ,
.Xr wcscoll_l 3 ,
.Xr wcsftime_l 3 ,
.Xr wcsnrtombs_l 3 ,
.Xr wcsrtombs_l 3 ,
.Xr wcstod_l 3 ,
.Xr wcstof_l 3 ,
.Xr wcstol_l 3 ,
.Xr wcstold_l 3 ,
.Xr wcstoll_l 3 ,
.Xr wcstoul_l 3 ,
.Xr wcstoull_l 3 ,
.Xr wcswidth_l 3 ,
.Xr wcsxfrm_l 3 ,
.Xr wctob_l 3 ,
.Xr wcwidth_l 3 ,
.Xr wprintf_l 3 ,
.Xr wscanf_l 3
.It Aq wctype.h
.Xr iswblank_l 3 ,
.Xr iswhexnumber_l 3 ,
.Xr iswideogram_l 3 ,
.Xr iswnumber_l 3 ,
.Xr iswphonogram_l 3 ,
.Xr iswrune_l 3 ,
.Xr iswspecial_l 3 ,
.Xr nextwctype_l 3 ,
.Xr towctrans_l 3 ,
.Xr wctrans_l 3
.It Aq xlocale.h
.Xr localeconv_l 3
.El