10d5acd74SJohn Marino.\" Copyright (c) 2011 The FreeBSD Foundation 20d5acd74SJohn Marino.\" All rights reserved. 30d5acd74SJohn Marino.\" 40d5acd74SJohn Marino.\" This documentation was written by David Chisnall under sponsorship from 50d5acd74SJohn Marino.\" the FreeBSD Foundation. 60d5acd74SJohn Marino.\" 70d5acd74SJohn Marino.\" Redistribution and use in source and binary forms, with or without 80d5acd74SJohn Marino.\" modification, are permitted provided that the following conditions 90d5acd74SJohn Marino.\" are met: 100d5acd74SJohn Marino.\" 1. Redistributions of source code must retain the above copyright 110d5acd74SJohn Marino.\" notice, this list of conditions and the following disclaimer. 120d5acd74SJohn Marino.\" 2. Redistributions in binary form must reproduce the above copyright 130d5acd74SJohn Marino.\" notice, this list of conditions and the following disclaimer in the 140d5acd74SJohn Marino.\" documentation and/or other materials provided with the distribution. 150d5acd74SJohn Marino.\" 160d5acd74SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 170d5acd74SJohn Marino.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 180d5acd74SJohn Marino.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 190d5acd74SJohn Marino.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 200d5acd74SJohn Marino.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 210d5acd74SJohn Marino.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 220d5acd74SJohn Marino.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 230d5acd74SJohn Marino.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 240d5acd74SJohn Marino.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 250d5acd74SJohn Marino.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 260d5acd74SJohn Marino.\" SUCH DAMAGE. 270d5acd74SJohn Marino.\" 280d5acd74SJohn Marino.\" $FreeBSD: head/lib/libc/locale/xlocale.3 250244 2013-05-04 17:06:47Z pluknet $ 290d5acd74SJohn Marino.\" 300d5acd74SJohn Marino.Dd September 17, 2011 310d5acd74SJohn Marino.Dt XLOCALE 3 320d5acd74SJohn Marino.Os 330d5acd74SJohn Marino.Sh NAME 340d5acd74SJohn Marino.Nm xlocale 350d5acd74SJohn Marino.Nd Thread-safe extended locale support 360d5acd74SJohn Marino.Sh LIBRARY 370d5acd74SJohn Marino.Lb libc 380d5acd74SJohn Marino.Sh SYNOPSIS 390d5acd74SJohn Marino.In xlocale.h 400d5acd74SJohn Marino.Sh DESCRIPTION 410d5acd74SJohn MarinoThe extended locale support includes a set of functions for setting 420d5acd74SJohn Marinothread-local locales, 430d5acd74SJohn Marinoas well convenience functions for performing locale-aware 440d5acd74SJohn Marinocalls with a specified locale. 450d5acd74SJohn Marino.Pp 460d5acd74SJohn MarinoThe core of the xlocale API is the 470d5acd74SJohn Marino.Fa locale_t 480d5acd74SJohn Marinotype. 490d5acd74SJohn MarinoThis is an opaque type encapsulating a locale. 500d5acd74SJohn MarinoInstances of this can be either set as the locale for a specific thread or 510d5acd74SJohn Marinopassed directly to the 520d5acd74SJohn Marino.Fa _l 530d5acd74SJohn Marinosuffixed variants of various standard C functions. 540d5acd74SJohn MarinoTwo special 550d5acd74SJohn Marino.Fa locale_t 560d5acd74SJohn Marinovalues are available: 570d5acd74SJohn Marino.Bl -bullet -offset indent 580d5acd74SJohn Marino.It 590d5acd74SJohn MarinoNULL refers to the current locale for the thread, 600d5acd74SJohn Marinoor to the global locale if no locale has been set for this thread. 610d5acd74SJohn Marino.It 62*5a3bf4efSSascha Wildner.Dv LC_GLOBAL_LOCALE 63*5a3bf4efSSascha Wildnerrefers to the global locale. 640d5acd74SJohn Marino.El 650d5acd74SJohn Marino.Pp 660d5acd74SJohn MarinoThe global locale is the locale set with the 670d5acd74SJohn Marino.Xr setlocale 3 680d5acd74SJohn Marinofunction. 690d5acd74SJohn Marino.Sh SEE ALSO 700d5acd74SJohn Marino.Xr duplocale 3 , 710d5acd74SJohn Marino.Xr freelocale 3 , 720d5acd74SJohn Marino.Xr localeconv 3 , 730d5acd74SJohn Marino.Xr newlocale 3 , 740d5acd74SJohn Marino.Xr querylocale 3 , 75b0a405dbSSascha Wildner.Xr uselocale 3 760d5acd74SJohn Marino.Sh CONVENIENCE FUNCTIONS 770d5acd74SJohn MarinoThe xlocale API includes a number of 780d5acd74SJohn Marino.Fa _l 790d5acd74SJohn Marinosuffixed convenience functions. 800d5acd74SJohn MarinoThese are variants of standard C functions 810d5acd74SJohn Marinothat have been modified to take an explicit 820d5acd74SJohn Marino.Fa locale_t 830d5acd74SJohn Marinoparameter as the final argument or, in the case of variadic functions, 840d5acd74SJohn Marinoas an additional argument directly before the format string. 85*5a3bf4efSSascha WildnerEach of these functions accepts either NULL or 86*5a3bf4efSSascha Wildner.Dv LC_GLOBAL_LOCALE . 870d5acd74SJohn MarinoIn these functions, NULL refers to the C locale, 880d5acd74SJohn Marinorather than the thread's current locale. 890d5acd74SJohn MarinoIf you wish to use the thread's current locale, 900d5acd74SJohn Marinothen use the unsuffixed version of the function. 910d5acd74SJohn Marino.Pp 920d5acd74SJohn MarinoThese functions are exposed by including 930d5acd74SJohn Marino.In xlocale.h 940d5acd74SJohn Marino.Em after 950d5acd74SJohn Marinoincluding the relevant headers for the standard variant. 960d5acd74SJohn MarinoFor example, the 970d5acd74SJohn Marino.Xr strtol_l 3 980d5acd74SJohn Marinofunction is exposed by including 990d5acd74SJohn Marino.In xlocale.h 1000d5acd74SJohn Marinoafter 1010d5acd74SJohn Marino.In stdlib.h , 1020d5acd74SJohn Marinowhich defines 1030d5acd74SJohn Marino.Xr strtol 3 . 1040d5acd74SJohn Marino.Pp 1050d5acd74SJohn MarinoFor reference, 1060d5acd74SJohn Marinoa complete list of the locale-aware functions that are available in this form, 1070d5acd74SJohn Marinoalong with the headers that expose them, is provided here: 108a2d2d73aSSascha Wildner.Bl -tag -width ".In monetary.h" 1090d5acd74SJohn Marino.It In wctype.h 1100d5acd74SJohn Marino.Xr iswalnum_l 3 , 1110d5acd74SJohn Marino.Xr iswalpha_l 3 , 1120d5acd74SJohn Marino.Xr iswcntrl_l 3 , 1130d5acd74SJohn Marino.Xr iswctype_l 3 , 1140d5acd74SJohn Marino.Xr iswdigit_l 3 , 1150d5acd74SJohn Marino.Xr iswgraph_l 3 , 1160d5acd74SJohn Marino.Xr iswlower_l 3 , 1170d5acd74SJohn Marino.Xr iswprint_l 3 , 1180d5acd74SJohn Marino.Xr iswpunct_l 3 , 1190d5acd74SJohn Marino.Xr iswspace_l 3 , 1200d5acd74SJohn Marino.Xr iswupper_l 3 , 1210d5acd74SJohn Marino.Xr iswxdigit_l 3 , 1220d5acd74SJohn Marino.Xr towlower_l 3 , 1230d5acd74SJohn Marino.Xr towupper_l 3 , 1240d5acd74SJohn Marino.Xr wctype_l 3 , 1250d5acd74SJohn Marino.It In ctype.h 1260d5acd74SJohn Marino.Xr digittoint_l 3 , 1270d5acd74SJohn Marino.Xr isalnum_l 3 , 1280d5acd74SJohn Marino.Xr isalpha_l 3 , 1290d5acd74SJohn Marino.Xr isblank_l 3 , 1300d5acd74SJohn Marino.Xr iscntrl_l 3 , 1310d5acd74SJohn Marino.Xr isdigit_l 3 , 1320d5acd74SJohn Marino.Xr isgraph_l 3 , 1330d5acd74SJohn Marino.Xr ishexnumber_l 3 , 1340d5acd74SJohn Marino.Xr isideogram_l 3 , 1350d5acd74SJohn Marino.Xr islower_l 3 , 1360d5acd74SJohn Marino.Xr isnumber_l 3 , 1370d5acd74SJohn Marino.Xr isphonogram_l 3 , 1380d5acd74SJohn Marino.Xr isprint_l 3 , 1390d5acd74SJohn Marino.Xr ispunct_l 3 , 1400d5acd74SJohn Marino.Xr isrune_l 3 , 1410d5acd74SJohn Marino.Xr isspace_l 3 , 1420d5acd74SJohn Marino.Xr isspecial_l 3 , 1430d5acd74SJohn Marino.Xr isupper_l 3 , 1440d5acd74SJohn Marino.Xr isxdigit_l 3 , 1450d5acd74SJohn Marino.Xr tolower_l 3 , 1460d5acd74SJohn Marino.Xr toupper_l 3 1470d5acd74SJohn Marino.It In inttypes.h 1480d5acd74SJohn Marino.Xr strtoimax_l 3 , 1490d5acd74SJohn Marino.Xr strtoumax_l 3 , 1500d5acd74SJohn Marino.Xr wcstoimax_l 3 , 1510d5acd74SJohn Marino.Xr wcstoumax_l 3 1520d5acd74SJohn Marino.It In langinfo.h 1530d5acd74SJohn Marino.Xr nl_langinfo_l 3 1540d5acd74SJohn Marino.It In monetary.h 1550d5acd74SJohn Marino.Xr strfmon_l 3 1560d5acd74SJohn Marino.It In stdio.h 1570d5acd74SJohn Marino.Xr asprintf_l 3 , 1580d5acd74SJohn Marino.Xr fprintf_l 3 , 1590d5acd74SJohn Marino.Xr fscanf_l 3 , 1600d5acd74SJohn Marino.Xr printf_l 3 , 1610d5acd74SJohn Marino.Xr scanf_l 3 , 1620d5acd74SJohn Marino.Xr snprintf_l 3 , 1630d5acd74SJohn Marino.Xr sprintf_l 3 , 1640d5acd74SJohn Marino.Xr sscanf_l 3 , 1650d5acd74SJohn Marino.Xr vasprintf_l 3 , 1660d5acd74SJohn Marino.Xr vfprintf_l 3 , 1670d5acd74SJohn Marino.Xr vfscanf_l 3 , 1680d5acd74SJohn Marino.Xr vprintf_l 3 , 1690d5acd74SJohn Marino.Xr vscanf_l 3 , 1700d5acd74SJohn Marino.Xr vsnprintf_l 3 , 1710d5acd74SJohn Marino.Xr vsprintf_l 3 , 1720d5acd74SJohn Marino.Xr vsscanf_l 3 1730d5acd74SJohn Marino.It In stdlib.h 1740d5acd74SJohn Marino.Xr atof_l 3 , 1750d5acd74SJohn Marino.Xr atoi_l 3 , 1760d5acd74SJohn Marino.Xr atol_l 3 , 1770d5acd74SJohn Marino.Xr atoll_l 3 , 1780d5acd74SJohn Marino.Xr mblen_l 3 , 1790d5acd74SJohn Marino.Xr mbstowcs_l 3 , 1800d5acd74SJohn Marino.Xr mbtowc_l 3 , 1810d5acd74SJohn Marino.Xr strtod_l 3 , 1820d5acd74SJohn Marino.Xr strtof_l 3 , 1830d5acd74SJohn Marino.Xr strtol_l 3 , 1840d5acd74SJohn Marino.Xr strtold_l 3 , 1850d5acd74SJohn Marino.Xr strtoll_l 3 , 1860d5acd74SJohn Marino.Xr strtoul_l 3 , 1870d5acd74SJohn Marino.Xr strtoull_l 3 , 1880d5acd74SJohn Marino.Xr wcstombs_l 3 , 1890d5acd74SJohn Marino.Xr wctomb_l 3 1900d5acd74SJohn Marino.It In string.h 1910d5acd74SJohn Marino.Xr strcoll_l 3 , 1920d5acd74SJohn Marino.Xr strxfrm_l 3 , 1930d5acd74SJohn Marino.Xr strcasecmp_l 3 , 1940d5acd74SJohn Marino.Xr strcasestr_l 3 , 1950d5acd74SJohn Marino.Xr strncasecmp_l 3 1960d5acd74SJohn Marino.It In time.h 1970d5acd74SJohn Marino.Xr strftime_l 3 1980d5acd74SJohn Marino.Xr strptime_l 3 1990d5acd74SJohn Marino.It In wchar.h 2000d5acd74SJohn Marino.Xr btowc_l 3 , 2010d5acd74SJohn Marino.Xr fgetwc_l 3 , 2020d5acd74SJohn Marino.Xr fgetws_l 3 , 2030d5acd74SJohn Marino.Xr fputwc_l 3 , 2040d5acd74SJohn Marino.Xr fputws_l 3 , 2050d5acd74SJohn Marino.Xr fwprintf_l 3 , 2060d5acd74SJohn Marino.Xr fwscanf_l 3 , 2070d5acd74SJohn Marino.Xr getwc_l 3 , 2080d5acd74SJohn Marino.Xr getwchar_l 3 , 2090d5acd74SJohn Marino.Xr mbrlen_l 3 , 2100d5acd74SJohn Marino.Xr mbrtowc_l 3 , 2110d5acd74SJohn Marino.Xr mbsinit_l 3 , 2120d5acd74SJohn Marino.Xr mbsnrtowcs_l 3 , 2130d5acd74SJohn Marino.Xr mbsrtowcs_l 3 , 2140d5acd74SJohn Marino.Xr putwc_l 3 , 2150d5acd74SJohn Marino.Xr putwchar_l 3 , 2160d5acd74SJohn Marino.Xr swprintf_l 3 , 2170d5acd74SJohn Marino.Xr swscanf_l 3 , 2180d5acd74SJohn Marino.Xr ungetwc_l 3 , 2190d5acd74SJohn Marino.Xr vfwprintf_l 3 , 2200d5acd74SJohn Marino.Xr vfwscanf_l 3 , 2210d5acd74SJohn Marino.Xr vswprintf_l 3 , 2220d5acd74SJohn Marino.Xr vswscanf_l 3 , 2230d5acd74SJohn Marino.Xr vwprintf_l 3 , 2240d5acd74SJohn Marino.Xr vwscanf_l 3 , 2250d5acd74SJohn Marino.Xr wcrtomb_l 3 , 2260d5acd74SJohn Marino.Xr wcscoll_l 3 , 2270d5acd74SJohn Marino.Xr wcsftime_l 3 , 2280d5acd74SJohn Marino.Xr wcsnrtombs_l 3 , 2290d5acd74SJohn Marino.Xr wcsrtombs_l 3 , 2300d5acd74SJohn Marino.Xr wcstod_l 3 , 2310d5acd74SJohn Marino.Xr wcstof_l 3 , 2320d5acd74SJohn Marino.Xr wcstol_l 3 , 2330d5acd74SJohn Marino.Xr wcstold_l 3 , 2340d5acd74SJohn Marino.Xr wcstoll_l 3 , 2350d5acd74SJohn Marino.Xr wcstoul_l 3 , 2360d5acd74SJohn Marino.Xr wcstoull_l 3 , 2370d5acd74SJohn Marino.Xr wcswidth_l 3 , 2380d5acd74SJohn Marino.Xr wcsxfrm_l 3 , 2390d5acd74SJohn Marino.Xr wctob_l 3 , 2400d5acd74SJohn Marino.Xr wcwidth_l 3 , 2410d5acd74SJohn Marino.Xr wprintf_l 3 , 2420d5acd74SJohn Marino.Xr wscanf_l 3 2430d5acd74SJohn Marino.It In wctype.h 2440d5acd74SJohn Marino.Xr iswblank_l 3 , 2450d5acd74SJohn Marino.Xr iswhexnumber_l 3 , 2460d5acd74SJohn Marino.Xr iswideogram_l 3 , 2470d5acd74SJohn Marino.Xr iswnumber_l 3 , 2480d5acd74SJohn Marino.Xr iswphonogram_l 3 , 2490d5acd74SJohn Marino.Xr iswrune_l 3 , 2500d5acd74SJohn Marino.Xr iswspecial_l 3 , 2510d5acd74SJohn Marino.Xr nextwctype_l 3 , 2520d5acd74SJohn Marino.Xr towctrans_l 3 , 2530d5acd74SJohn Marino.Xr wctrans_l 3 2540d5acd74SJohn Marino.It In xlocale.h 2550d5acd74SJohn Marino.Xr localeconv_l 3 2560d5acd74SJohn Marino.El 2570d5acd74SJohn Marino.Sh STANDARDS 2580d5acd74SJohn MarinoThe functions 2590d5acd74SJohn Marinoconform to 2600d5acd74SJohn Marino.St -p1003.1-2008 . 2610d5acd74SJohn Marino.Sh HISTORY 2620d5acd74SJohn MarinoThe xlocale APIs first appeared in Darwin 8.0. 2630d5acd74SJohn MarinoThis implementation was written by David Chisnall, 2648d975f05SSascha Wildnerunder sponsorship from the 2658d975f05SSascha Wildner.Fx 2668d975f05SSascha WildnerFoundation and first appeared in 2670d5acd74SJohn Marino.Fx 9.1 . 2680d5acd74SJohn Marino.Sh CAVEATS 2690d5acd74SJohn MarinoThe 2700d5acd74SJohn Marino.Xr setlocale 3 2710d5acd74SJohn Marinofunction, and others in the family, refer to the global locale. 2720d5acd74SJohn MarinoOther functions that depend on the locale, however, 2730d5acd74SJohn Marinowill take the thread-local locale if one has been set. 2740d5acd74SJohn MarinoThis means that the idiom of setting the locale using 2750d5acd74SJohn Marino.Xr setlocale 3 , 2760d5acd74SJohn Marinocalling a locale-dependent function, 2770d5acd74SJohn Marinoand then restoring the locale will not 2780d5acd74SJohn Marinohave the expected behavior if the current thread has had a locale set using 2790d5acd74SJohn Marino.Xr uselocale 3 . 2800d5acd74SJohn MarinoYou should avoid this idiom and prefer to use the 2810d5acd74SJohn Marino.Fa _l 2820d5acd74SJohn Marinosuffixed versions instead. 283