]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - lib/libc/locale/xlocale.3
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / lib / libc / locale / xlocale.3
1 .\" Copyright (c) 2011 The FreeBSD Foundation
2 .\" All rights reserved.
3 .\"
4 .\" This documentation was written by David Chisnall under sponsorship from
5 .\" the FreeBSD Foundation.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\" $FreeBSD$
29 .\"
30 .Dd September 17 2011
31 .Dt XLOCALE 3
32 .Os
33 .Sh NAME
34 .Nm xlocale
35 .Nd Thread-safe extended locale support.
36 .Sh LIBRARY
37 .Lb libc
38 .Sh SYNOPSIS
39 .In xlocale.h
40 .Sh DESCRIPTION
41 The extended locale support includes a set of functions for setting
42 thread-local locales,
43 as well convenience functions for performing locale-aware
44 calls with a specified locale.
45 .Pp
46 The core of the xlocale API is the
47 .Fa locale_t
48 type.
49 This is an opaque type encapsulating a locale.
50 Instances of this can be either set as the locale for a specific thread or
51 passed directly to the
52 .Fa _l
53 suffixed variants of various standard C functions.
54 Two special
55 .Fa locale_t
56 values are available:
57 .Bl -bullet -offset indent
58 .It
59 NULL refers to the current locale for the thread,
60 or to the global locale if no locale has been set for this thread.
61 .It
62 LC_GLOBAL_LOCALE refers to the global locale.
63 .El
64 .Pp
65 The global locale is the locale set with the
66 .Xr setlocale 3
67 function.
68 .Sh CAVEATS
69 The
70 .Xr setlocale 3
71 function, and others in the family, refer to the global locale.
72 Other functions that depend on the locale, however,
73 will take the thread-local locale if one has been set.
74 This means that the idiom of setting the locale using
75 .Xr setlocale 3 ,
76 calling a locale-dependent function,
77 and then restoring the locale will not
78 have the expected behavior if the current thread has had a locale set using
79 .Xr uselocale 3 .
80 You should avoid this idiom and prefer to use the
81 .Fa _l
82 suffixed versions instead.
83 .Sh SEE ALSO
84 .Xr duplocale 3 ,
85 .Xr freelocale 3 ,
86 .Xr localeconv 3 ,
87 .Xr newlocale 3 ,
88 .Xr querylocale 3 ,
89 .Xr uselocale 3 ,
90 .Sh CONVENIENCE FUNCTIONS
91 The xlocale API includes a number of
92 .Fa _l
93 suffixed convenience functions.
94 These are variants of standard C functions
95 that have been modified to take an explicit
96 .Fa locale_t
97 parameter as the final argument or, in the case of variadic functions,
98 as an additional argument directly before the format string.
99 Each of these functions accepts either NULL or LC_GLOBAL_LOCALE.
100 In these functions, NULL refers to the C locale,
101 rather than the thread's current locale.
102 If you wish to use the thread's current locale,
103 then use the unsuffixed version of the function.
104 .Pp
105 These functions are exposed by including
106 .In xlocale.h
107 .Em after
108 including the relevant headers for the standard variant.
109 For example, the
110 .Xr strtol_l 3
111 function is exposed by including
112 .In xlocale.h
113 after
114 .In stdlib.h ,
115 which defines
116 .Xr strtol 3 .
117 .Pp
118 For reference,
119 a complete list of the locale-aware functions that are available in this form,
120 along with the headers that expose them, is provided here:
121 .Pp
122 .Bl -tag -width "<monetary.h> "
123 .It In wctype.h
124 .Xr iswalnum_l 3 ,
125 .Xr iswalpha_l 3 ,
126 .Xr iswcntrl_l 3 ,
127 .Xr iswctype_l 3 ,
128 .Xr iswdigit_l 3 ,
129 .Xr iswgraph_l 3 ,
130 .Xr iswlower_l 3 ,
131 .Xr iswprint_l 3 ,
132 .Xr iswpunct_l 3 ,
133 .Xr iswspace_l 3 ,
134 .Xr iswupper_l 3 ,
135 .Xr iswxdigit_l 3 ,
136 .Xr towlower_l 3 ,
137 .Xr towupper_l 3 ,
138 .Xr wctype_l 3 ,
139 .It In ctype.h
140 .Xr digittoint_l 3 ,
141 .Xr isalnum_l 3 ,
142 .Xr isalpha_l 3 ,
143 .Xr isblank_l 3 ,
144 .Xr iscntrl_l 3 ,
145 .Xr isdigit_l 3 ,
146 .Xr isgraph_l 3 ,
147 .Xr ishexnumber_l 3 ,
148 .Xr isideogram_l 3 ,
149 .Xr islower_l 3 ,
150 .Xr isnumber_l 3 ,
151 .Xr isphonogram_l 3 ,
152 .Xr isprint_l 3 ,
153 .Xr ispunct_l 3 ,
154 .Xr isrune_l 3 ,
155 .Xr isspace_l 3 ,
156 .Xr isspecial_l 3 ,
157 .Xr isupper_l 3 ,
158 .Xr isxdigit_l 3 ,
159 .Xr tolower_l 3 ,
160 .Xr toupper_l 3
161 .It In inttypes.h
162 .Xr strtoimax_l 3 ,
163 .Xr strtoumax_l 3 ,
164 .Xr wcstoimax_l 3 ,
165 .Xr wcstoumax_l 3
166 .It In langinfo.h
167 .Xr nl_langinfo_l 3
168 .It In monetary.h
169 .Xr strfmon_l 3
170 .It In stdio.h
171 .Xr asprintf_l 3 ,
172 .Xr fprintf_l 3 ,
173 .Xr fscanf_l 3 ,
174 .Xr printf_l 3 ,
175 .Xr scanf_l 3 ,
176 .Xr snprintf_l 3 ,
177 .Xr sprintf_l 3 ,
178 .Xr sscanf_l 3 ,
179 .Xr vasprintf_l 3 ,
180 .Xr vfprintf_l 3 ,
181 .Xr vfscanf_l 3 ,
182 .Xr vprintf_l 3 ,
183 .Xr vscanf_l 3 ,
184 .Xr vsnprintf_l 3 ,
185 .Xr vsprintf_l 3 ,
186 .Xr vsscanf_l 3
187 .It In stdlib.h
188 .Xr atof_l 3 ,
189 .Xr atoi_l 3 ,
190 .Xr atol_l 3 ,
191 .Xr atoll_l 3 ,
192 .Xr mblen_l 3 ,
193 .Xr mbstowcs_l 3 ,
194 .Xr mbtowc_l 3 ,
195 .Xr strtod_l 3 ,
196 .Xr strtof_l 3 ,
197 .Xr strtol_l 3 ,
198 .Xr strtold_l 3 ,
199 .Xr strtoll_l 3 ,
200 .Xr strtoq_l 3 ,
201 .Xr strtoul_l 3 ,
202 .Xr strtoull_l 3 ,
203 .Xr strtouq_l 3 ,
204 .Xr wcstombs_l 3 ,
205 .Xr wctomb_l 3
206 .It In string.h
207 .Xr strcoll_l 3 ,
208 .Xr strxfrm_l 3 ,
209 .Xr strcasecmp_l 3 ,
210 .Xr strcasestr_l 3 ,
211 .Xr strncasecmp_l 3
212 .It In time.h
213 .Xr strftime_l 3
214 .Xr strptime_l 3
215 .It In wchar.h
216 .Xr btowc_l 3 ,
217 .Xr fgetwc_l 3 ,
218 .Xr fgetws_l 3 ,
219 .Xr fputwc_l 3 ,
220 .Xr fputws_l 3 ,
221 .Xr fwprintf_l 3 ,
222 .Xr fwscanf_l 3 ,
223 .Xr getwc_l 3 ,
224 .Xr getwchar_l 3 ,
225 .Xr mbrlen_l 3 ,
226 .Xr mbrtowc_l 3 ,
227 .Xr mbsinit_l 3 ,
228 .Xr mbsnrtowcs_l 3 ,
229 .Xr mbsrtowcs_l 3 ,
230 .Xr putwc_l 3 ,
231 .Xr putwchar_l 3 ,
232 .Xr swprintf_l 3 ,
233 .Xr swscanf_l 3 ,
234 .Xr ungetwc_l 3 ,
235 .Xr vfwprintf_l 3 ,
236 .Xr vfwscanf_l 3 ,
237 .Xr vswprintf_l 3 ,
238 .Xr vswscanf_l 3 ,
239 .Xr vwprintf_l 3 ,
240 .Xr vwscanf_l 3 ,
241 .Xr wcrtomb_l 3 ,
242 .Xr wcscoll_l 3 ,
243 .Xr wcsftime_l 3 ,
244 .Xr wcsnrtombs_l 3 ,
245 .Xr wcsrtombs_l 3 ,
246 .Xr wcstod_l 3 ,
247 .Xr wcstof_l 3 ,
248 .Xr wcstol_l 3 ,
249 .Xr wcstold_l 3 ,
250 .Xr wcstoll_l 3 ,
251 .Xr wcstoul_l 3 ,
252 .Xr wcstoull_l 3 ,
253 .Xr wcswidth_l 3 ,
254 .Xr wcsxfrm_l 3 ,
255 .Xr wctob_l 3 ,
256 .Xr wcwidth_l 3 ,
257 .Xr wprintf_l 3 ,
258 .Xr wscanf_l 3
259 .It In wctype.h
260 .Xr iswblank_l 3 ,
261 .Xr iswhexnumber_l 3 ,
262 .Xr iswideogram_l 3 ,
263 .Xr iswnumber_l 3 ,
264 .Xr iswphonogram_l 3 ,
265 .Xr iswrune_l 3 ,
266 .Xr iswspecial_l 3 ,
267 .Xr nextwctype_l 3 ,
268 .Xr towctrans_l 3 ,
269 .Xr wctrans_l 3
270 .It In xlocale.h
271 .Xr localeconv_l 3
272 .El
273 .Sh STANDARDS
274 The functions
275 conform to
276 .St -p1003.1-2008 .
277 .Sh HISTORY
278 The xlocale APIs first appeared in Darwin 8.0.
279 This implementation was written by David Chisnall,
280 under sponsorship from the FreeBSD Foundation and first appeared in
281 .Fx 9.1 .