2 .\" The Regents of the University of California. All rights reserved.
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Donn Seeley at BSDI.
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.
15 .\" 3. All advertising materials mentioning features or use of this software
16 .\" must display the following acknowledgement:
17 .\" This product includes software developed by the University of
18 .\" California, Berkeley and its contributors.
19 .\" 4. Neither the name of the University nor the names of its contributors
20 .\" may be used to endorse or promote products derived from this software
21 .\" without specific prior written permission.
23 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 .\" @(#)setlocale.3 8.1 (Berkeley) 6/9/93
36 .\" $FreeBSD: src/lib/libc/locale/setlocale.3,v 1.15.2.5 2001/12/14 18:33:55 ru Exp $
44 .Nd natural language formatting for C
50 .Fn setlocale "int category" "const char *locale"
56 function sets the C library's notion
57 of natural language formatting style
58 for particular sets of routines.
59 Each such style is called a
61 and is invoked using an appropriate name passed as a C string.
64 routine returns the current locale's parameters
65 for formatting numbers.
69 function recognizes several categories of routines.
70 These are the categories and the sets of routines they select:
72 .Bl -tag -width LC_MONETARY
74 Set the entire locale generically.
76 Set a locale for string collation routines.
77 This controls alphabetic ordering in
89 This controls recognition of upper and lower case,
90 alphabetic or non-alphabetic characters,
91 and so on. The real work is done by the
95 Set a locale for message catalogs, see
99 Set a locale for formatting monetary values;
104 Set a locale for formatting numbers.
105 This controls the formatting of decimal points
106 in input and output of floating point numbers
111 as well as values returned by
114 Set a locale for formatting dates and times using the
119 Only three locales are defined by default,
122 which denotes the native environment, and the
126 locales, which denote the C language environment.
133 to return the current locale.
134 By default, C programs start in the
137 The only function in the library that sets the locale is
139 the locale is never changed as a side effect of some other routine.
143 function returns a pointer to a structure
144 which provides parameters for formatting numbers,
145 especially currency values:
146 .Bd -literal -offset indent
151 char *int_curr_symbol;
152 char *currency_symbol;
153 char *mon_decimal_point;
154 char *mon_thousands_sep;
158 char int_frac_digits;
169 The individual fields have the following meanings:
171 .Bl -tag -width mon_decimal_point
173 The decimal point character, except for currency values.
175 The separator between groups of digits
176 before the decimal point, except for currency values.
178 The sizes of the groups of digits, except for currency values.
179 This is a pointer to a vector of integers, each of size
181 representing group size from low order digit groups
182 to high order (right to left).
183 The list may be terminated with 0 or
185 If the list is terminated with 0,
186 the last group size before the 0 is repeated to account for all the digits.
187 If the list is terminated with
189 no more grouping is performed.
190 .It Fa int_curr_symbol
191 The standardized international currency symbol.
192 .It Fa currency_symbol
193 The local currency symbol.
194 .It Fa mon_decimal_point
195 The decimal point character for currency values.
196 .It Fa mon_thousands_sep
197 The separator for digit groups in currency values.
201 but for currency values.
203 The character used to denote nonnegative currency values,
204 usually the empty string.
206 The character used to denote negative currency values,
207 usually a minus sign.
208 .It Fa int_frac_digits
209 The number of digits after the decimal point
210 in an international-style currency value.
212 The number of digits after the decimal point
213 in the local style for currency values.
215 1 if the currency symbol precedes the currency value
216 for nonnegative values, 0 if it follows.
217 .It Fa p_sep_by_space
218 1 if a space is inserted between the currency symbol
219 and the currency value for nonnegative values, 0 otherwise.
223 but for negative values.
224 .It Fa n_sep_by_space
227 but for negative values.
231 with respect to a nonnegative quantity and the
232 .Fa currency_symbol ,
234 .Bl -tag -width 3n -compact
236 Parentheses around the entire string.
243 .Fa currency_symbol .
246 .Fa currency_symbol .
251 but for negative currency values.
254 Unless mentioned above,
255 an empty string as a value for a field
256 indicates a zero length result or
257 a value that is not in the current locale.
260 result similarly denotes an unavailable value.
266 and fails to change the locale
267 if the given combination of
274 function returns a pointer to a static object
275 which may be altered by later calls to
280 .Bl -tag -width /usr/share/locale/locale/category -compact
281 .It Pa $PATH_LOCALE/ Ns Em locale/category
282 .It Pa /usr/share/locale/ Ns Em locale/category
283 locale file for the locale
312 functions first appeared in
315 The current implementation supports only the
319 locales for all but the
326 In spite of the gnarly currency support in
328 the standards don't include any functions
329 for generalized currency formatting.
333 could lead to misleading results until we have a real time currency
338 are personal choices and should not be wrapped up with the other categories.