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