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