1 .\" Copyright (c) 2011 The FreeBSD Foundation
2 .\" All rights reserved.
4 .\" This documentation was written by David Chisnall under sponsorship from
5 .\" the FreeBSD Foundation.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
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.
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
28 .\" $FreeBSD: head/lib/libc/locale/xlocale.3 250244 2013-05-04 17:06:47Z pluknet $
30 .Dd September 17, 2011
35 .Nd Thread-safe extended locale support
41 The extended locale support includes a set of functions for setting
43 as well convenience functions for performing locale-aware
44 calls with a specified locale.
46 The core of the xlocale API is the
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
53 suffixed variants of various standard C functions.
57 .Bl -bullet -offset indent
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.
63 refers to the global locale.
66 The global locale is the locale set with the
76 .Sh CONVENIENCE FUNCTIONS
77 The xlocale API includes a number of
79 suffixed convenience functions.
80 These are variants of standard C functions
81 that have been modified to take an explicit
83 parameter as the final argument or, in the case of variadic functions,
84 as an additional argument directly before the format string.
85 Each of these functions accepts either NULL or
86 .Dv LC_GLOBAL_LOCALE .
87 In these functions, NULL refers to the C locale,
88 rather than the thread's current locale.
89 If you wish to use the thread's current locale,
90 then use the unsuffixed version of the function.
92 These functions are exposed by including
95 including the relevant headers for the standard variant.
98 function is exposed by including
106 a complete list of the locale-aware functions that are available in this form,
107 along with the headers that expose them, is provided here:
108 .Bl -tag -width ".In monetary.h"
133 .Xr ishexnumber_l 3 ,
137 .Xr isphonogram_l 3 ,
245 .Xr iswhexnumber_l 3 ,
246 .Xr iswideogram_l 3 ,
248 .Xr iswphonogram_l 3 ,
262 The xlocale APIs first appeared in Darwin 8.0.
263 This implementation was written by David Chisnall,
264 under sponsorship from the
266 Foundation and first appeared in
271 function, and others in the family, refer to the global locale.
272 Other functions that depend on the locale, however,
273 will take the thread-local locale if one has been set.
274 This means that the idiom of setting the locale using
276 calling a locale-dependent function,
277 and then restoring the locale will not
278 have the expected behavior if the current thread has had a locale set using
280 You should avoid this idiom and prefer to use the
282 suffixed versions instead.