]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - lib/libc/locale/localeconv.3
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.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 .\" 4. 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$
34 .\"
35 .Dd November 21, 2003
36 .Dt LOCALECONV 3
37 .Os
38 .Sh NAME
39 .Nm localeconv
40 .Nd natural language formatting for C
41 .Sh LIBRARY
42 .Lb libc
43 .Sh SYNOPSIS
44 .In locale.h
45 .Ft struct lconv *
46 .Fn localeconv "void"
47 .Sh DESCRIPTION
48 The
49 .Fn localeconv
50 function returns a pointer to a structure
51 which provides parameters for formatting numbers,
52 especially currency values:
53 .Bd -literal -offset indent
54 struct lconv {
55         char    *decimal_point;
56         char    *thousands_sep;
57         char    *grouping;
58         char    *int_curr_symbol;
59         char    *currency_symbol;
60         char    *mon_decimal_point;
61         char    *mon_thousands_sep;
62         char    *mon_grouping;
63         char    *positive_sign;
64         char    *negative_sign;
65         char    int_frac_digits;
66         char    frac_digits;
67         char    p_cs_precedes;
68         char    p_sep_by_space;
69         char    n_cs_precedes;
70         char    n_sep_by_space;
71         char    p_sign_posn;
72         char    n_sign_posn;
73         char    int_p_cs_precedes;
74         char    int_n_cs_precedes;
75         char    int_p_sep_by_space;
76         char    int_n_sep_by_space;
77         char    int_p_sign_posn;
78         char    int_n_sign_posn;
79 };
80 .Ed
81 .Pp
82 The individual fields have the following meanings:
83 .Bl -tag -width mon_decimal_point
84 .It Va decimal_point
85 The decimal point character, except for currency values,
86 cannot be an empty string.
87 .It Va thousands_sep
88 The separator between groups of digits
89 before the decimal point, except for currency values.
90 .It Va grouping
91 The sizes of the groups of digits, except for currency values.
92 This is a pointer to a vector of integers, each of size
93 .Vt char ,
94 representing group size from low order digit groups
95 to high order (right to left).
96 The list may be terminated with 0 or
97 .Dv CHAR_MAX .
98 If the list is terminated with 0,
99 the last group size before the 0 is repeated to account for all the digits.
100 If the list is terminated with
101 .Dv CHAR_MAX ,
102 no more grouping is performed.
103 .It Va int_curr_symbol
104 The standardized international currency symbol.
105 .It Va currency_symbol
106 The local currency symbol.
107 .It Va mon_decimal_point
108 The decimal point character for currency values.
109 .It Va mon_thousands_sep
110 The separator for digit groups in currency values.
111 .It Va mon_grouping
112 Like
113 .Va grouping
114 but for currency values.
115 .It Va positive_sign
116 The character used to denote nonnegative currency values,
117 usually the empty string.
118 .It Va negative_sign
119 The character used to denote negative currency values,
120 usually a minus sign.
121 .It Va int_frac_digits
122 The number of digits after the decimal point
123 in an international-style currency value.
124 .It Va frac_digits
125 The number of digits after the decimal point
126 in the local style for currency values.
127 .It Va p_cs_precedes
128 1 if the currency symbol precedes the currency value
129 for nonnegative values, 0 if it follows.
130 .It Va p_sep_by_space
131 1 if a space is inserted between the currency symbol
132 and the currency value for nonnegative values, 0 otherwise.
133 .It Va n_cs_precedes
134 Like
135 .Va p_cs_precedes
136 but for negative values.
137 .It Va n_sep_by_space
138 Like
139 .Va p_sep_by_space
140 but for negative values.
141 .It Va p_sign_posn
142 The location of the
143 .Va positive_sign
144 with respect to a nonnegative quantity and the
145 .Va currency_symbol ,
146 coded as follows:
147 .Pp
148 .Bl -tag -width 3n -compact
149 .It Li 0
150 Parentheses around the entire string.
151 .It Li 1
152 Before the string.
153 .It Li 2
154 After the string.
155 .It Li 3
156 Just before
157 .Va currency_symbol .
158 .It Li 4
159 Just after
160 .Va currency_symbol .
161 .El
162 .It Va n_sign_posn
163 Like
164 .Va p_sign_posn
165 but for negative currency values.
166 .It Va int_p_cs_precedes
167 Same as
168 .Va p_cs_precedes ,
169 but for internationally formatted monetary quantities.
170 .It Va int_n_cs_precedes
171 Same as
172 .Va n_cs_precedes ,
173 but for internationally formatted monetary quantities.
174 .It Va int_p_sep_by_space
175 Same as
176 .Va p_sep_by_space ,
177 but for internationally formatted monetary quantities.
178 .It Va int_n_sep_by_space
179 Same as
180 .Va n_sep_by_space ,
181 but for internationally formatted monetary quantities.
182 .It Va int_p_sign_posn
183 Same as
184 .Va p_sign_posn ,
185 but for internationally formatted monetary quantities.
186 .It Va int_n_sign_posn
187 Same as
188 .Va n_sign_posn ,
189 but for internationally formatted monetary quantities.
190 .El
191 .Pp
192 Unless mentioned above,
193 an empty string as a value for a field
194 indicates a zero length result or
195 a value that is not in the current locale.
196 A
197 .Dv CHAR_MAX
198 result similarly denotes an unavailable value.
199 .Sh RETURN VALUES
200 The
201 .Fn localeconv
202 function returns a pointer to a static object
203 which may be altered by later calls to
204 .Xr setlocale 3
205 or
206 .Fn localeconv .
207 .Sh ERRORS
208 No errors are defined.
209 .Sh SEE ALSO
210 .Xr setlocale 3 ,
211 .Xr strfmon 3
212 .Sh STANDARDS
213 The
214 .Fn localeconv
215 function conforms to
216 .St -isoC-99 .
217 .Sh HISTORY
218 The
219 .Fn localeconv
220 function first appeared in
221 .Bx 4.4 .