Upgrade libedit. 1/2
[dragonfly.git] / lib / libc / locale / localeconv.3
1 .\" Copyright (c) 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Donn Seeley at BSDI.
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 .\" 3. Neither the name of the University nor the names of its contributors
16 .\"    may be used to endorse or promote products derived from this software
17 .\"    without specific prior written permission.
18 .\"
19 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 .\" SUCH DAMAGE.
30 .\"
31 .\" From @(#)setlocale.3        8.1 (Berkeley) 6/9/93
32 .\" From FreeBSD: src/lib/libc/locale/setlocale.3,v 1.28 2003/11/15 02:26:04 tjr Exp
33 .\" $FreeBSD: head/lib/libc/locale/localeconv.3 228199 2011-12-02 11:55:09Z obrien $
34 .\"
35 .Dd November 21, 2003
36 .Dt LOCALECONV 3
37 .Os
38 .Sh NAME
39 .Nm localeconv ,
40 .Nm localeconv_l
41 .Nd natural language formatting for C
42 .Sh LIBRARY
43 .Lb libc
44 .Sh SYNOPSIS
45 .In locale.h
46 .Ft struct lconv *
47 .Fn localeconv "void"
48 .In xlocale.h
49 .Ft struct lconv *
50 .Fn localeconv_l "locale_t locale"
51 .Sh DESCRIPTION
52 The
53 .Fn localeconv
54 function returns a pointer to a structure
55 which provides parameters for formatting numbers,
56 especially currency values:
57 .Bd -literal -offset indent
58 struct lconv {
59         char    *decimal_point;
60         char    *thousands_sep;
61         char    *grouping;
62         char    *int_curr_symbol;
63         char    *currency_symbol;
64         char    *mon_decimal_point;
65         char    *mon_thousands_sep;
66         char    *mon_grouping;
67         char    *positive_sign;
68         char    *negative_sign;
69         char    int_frac_digits;
70         char    frac_digits;
71         char    p_cs_precedes;
72         char    p_sep_by_space;
73         char    n_cs_precedes;
74         char    n_sep_by_space;
75         char    p_sign_posn;
76         char    n_sign_posn;
77         char    int_p_cs_precedes;
78         char    int_n_cs_precedes;
79         char    int_p_sep_by_space;
80         char    int_n_sep_by_space;
81         char    int_p_sign_posn;
82         char    int_n_sign_posn;
83 };
84 .Ed
85 .Pp
86 The individual fields have the following meanings:
87 .Bl -tag -width mon_decimal_point
88 .It Va decimal_point
89 The decimal point character, except for currency values,
90 cannot be an empty string.
91 .It Va thousands_sep
92 The separator between groups of digits
93 before the decimal point, except for currency values.
94 .It Va grouping
95 The sizes of the groups of digits, except for currency values.
96 This is a pointer to a vector of integers, each of size
97 .Vt char ,
98 representing group size from low order digit groups
99 to high order (right to left).
100 The list may be terminated with 0 or
101 .Dv CHAR_MAX .
102 If the list is terminated with 0,
103 the last group size before the 0 is repeated to account for all the digits.
104 If the list is terminated with
105 .Dv CHAR_MAX ,
106 no more grouping is performed.
107 .It Va int_curr_symbol
108 The standardized international currency symbol.
109 .It Va currency_symbol
110 The local currency symbol.
111 .It Va mon_decimal_point
112 The decimal point character for currency values.
113 .It Va mon_thousands_sep
114 The separator for digit groups in currency values.
115 .It Va mon_grouping
116 Like
117 .Va grouping
118 but for currency values.
119 .It Va positive_sign
120 The character used to denote nonnegative currency values,
121 usually the empty string.
122 .It Va negative_sign
123 The character used to denote negative currency values,
124 usually a minus sign.
125 .It Va int_frac_digits
126 The number of digits after the decimal point
127 in an international-style currency value.
128 .It Va frac_digits
129 The number of digits after the decimal point
130 in the local style for currency values.
131 .It Va p_cs_precedes
132 1 if the currency symbol precedes the currency value
133 for nonnegative values, 0 if it follows.
134 .It Va p_sep_by_space
135 1 if a space is inserted between the currency symbol
136 and the currency value for nonnegative values, 0 otherwise.
137 .It Va n_cs_precedes
138 Like
139 .Va p_cs_precedes
140 but for negative values.
141 .It Va n_sep_by_space
142 Like
143 .Va p_sep_by_space
144 but for negative values.
145 .It Va p_sign_posn
146 The location of the
147 .Va positive_sign
148 with respect to a nonnegative quantity and the
149 .Va currency_symbol ,
150 coded as follows:
151 .Pp
152 .Bl -tag -width 3n -compact
153 .It Li 0
154 Parentheses around the entire string.
155 .It Li 1
156 Before the string.
157 .It Li 2
158 After the string.
159 .It Li 3
160 Just before
161 .Va currency_symbol .
162 .It Li 4
163 Just after
164 .Va currency_symbol .
165 .El
166 .It Va n_sign_posn
167 Like
168 .Va p_sign_posn
169 but for negative currency values.
170 .It Va int_p_cs_precedes
171 Same as
172 .Va p_cs_precedes ,
173 but for internationally formatted monetary quantities.
174 .It Va int_n_cs_precedes
175 Same as
176 .Va n_cs_precedes ,
177 but for internationally formatted monetary quantities.
178 .It Va int_p_sep_by_space
179 Same as
180 .Va p_sep_by_space ,
181 but for internationally formatted monetary quantities.
182 .It Va int_n_sep_by_space
183 Same as
184 .Va n_sep_by_space ,
185 but for internationally formatted monetary quantities.
186 .It Va int_p_sign_posn
187 Same as
188 .Va p_sign_posn ,
189 but for internationally formatted monetary quantities.
190 .It Va int_n_sign_posn
191 Same as
192 .Va n_sign_posn ,
193 but for internationally formatted monetary quantities.
194 .El
195 .Pp
196 Unless mentioned above,
197 an empty string as a value for a field
198 indicates a zero length result or
199 a value that is not in the current locale.
200 A
201 .Dv CHAR_MAX
202 result similarly denotes an unavailable value.
203 .Pp
204 The
205 .Fn localeconv_l
206 function takes an explicit locale parameter.  For more information, see
207 .Xr xlocale 3 .
208 .Sh RETURN VALUES
209 The
210 .Fn localeconv
211 function returns a pointer to a static object
212 which may be altered by later calls to
213 .Xr setlocale 3
214 or
215 .Fn localeconv .
216 The return value for
217 .Fn localeconv_l
218 is stored with the locale.
219 It will remain valid until a subsequent call to
220 .Xr freelocale 3 .
221 If a thread-local locale is in effect then the return value from
222 .Fn localeconv
223 will remain valid until the locale is destroyed.
224 .Sh ERRORS
225 No errors are defined.
226 .Sh SEE ALSO
227 .Xr setlocale 3 ,
228 .Xr strfmon 3 ,
229 .Xr xlocale 3
230 .Sh STANDARDS
231 The
232 .Fn localeconv
233 function conforms to
234 .St -isoC-99 .
235 .Sh HISTORY
236 The
237 .Fn localeconv
238 function first appeared in
239 .Bx 4.4 .