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