]> git.saurik.com Git - apple/libc.git/blame - stdlib/strfmon.3
Libc-498.1.1.tar.gz
[apple/libc.git] / stdlib / strfmon.3
CommitLineData
224c7076
A
1.\" Copyright (c) 2001 Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD: src/lib/libc/stdlib/strfmon.3,v 1.7 2003/01/06 06:21:25 tjr Exp $
26.\"
27.Dd October 12, 2002
28.Dt STRFMON 3
29.Os
30.Sh NAME
31.Nm strfmon ,
32.Nm strfmon_l
33.Nd convert monetary value to string
34.Sh LIBRARY
35.Lb libc
36.Sh SYNOPSIS
37.In monetary.h
38.Ft ssize_t
39.Fo strfmon
40.Fa "char *restrict s"
41.Fa "size_t maxsize"
42.Fa "const char *restrict format"
43.Fa "..."
44.Fc
45.In monetary.h
46.In xlocale.h
47.Ft ssize_t
48.Fo strfmon_l
49.Fa "char *restrict s"
50.Fa "size_t maxsize"
51.Fa "locale_t loc"
52.Fa "const char *restrict format"
53.Fa "..."
54.Fc
55.Sh DESCRIPTION
56The
57.Fn strfmon
58function places characters into the array pointed to by
59.Fa s ,
60as controlled by the string pointed to by
61.Fa format .
62No more than
63.Fa maxsize
64bytes are placed into the array.
65.Pp
66While the
67.Fn strfmon
68function uses the current locale, the
69.Fn strfmon_l
70function may be passed a locale directly. See
71.Xr xlocale 3
72for more information.
73.Pp
74The format string is composed of zero or more directives:
75ordinary characters (not
76.Cm % ) ,
77which are copied unchanged to the output stream; and conversion
78specifications, each of which results in fetching zero or more subsequent
79arguments.
80Each conversion specification is introduced by the
81.Cm %
82character.
83After the
84.Cm % ,
85the following appear in sequence:
86.Bl -bullet
87.It
88Zero or more of the following flags:
89.Bl -tag -width "XXX"
90.It Cm = Ns Ar f
91A
92.Sq Cm =
93character followed by another character
94.Ar f
95which is used as the numeric fill character.
96.It Cm ^
97Do not use grouping characters, regardless of the current locale default.
98.It Cm +
99Represent positive values by prefixing them with a positive sign,
100and negative values by prefixing them with a negative sign.
101This is the default.
102.It Cm \&(
103Enclose negative values in parentheses.
104.It Cm \&!
105Do not include a currency symbol in the output.
106.It Cm \-
107Left justify the result.
108Only valid when a field width is specified.
109.El
110.It
111An optional minimum field width as a decimal number.
112By default, there is no minimum width.
113.It
114A
115.Sq Cm #
116sign followed by a decimal number specifying the maximum
117expected number of digits after the radix character.
118.It
119A
120.Sq Cm \&.
121character followed by a decimal number specifying the number
122the number of digits after the radix character.
123.It
124One of the following conversion specifiers:
125.Bl -tag -width "XXX"
126.It Cm i
127The
128.Vt double
129argument is formatted as an international monetary amount.
130.It Cm n
131The
132.Vt double
133argument is formatted as a national monetary amount.
134.It Cm %
135A
136.Sq Li %
137character is written.
138.El
139.El
140.Sh RETURN VALUES
141If the total number of resulting bytes, including the terminating
142.Dv NULL
143byte, is not more than
144.Fa maxsize ,
145.Fn strfmon
146returns the number of bytes placed into the array pointed to by
147.Fa s ,
148not including the terminating
149.Dv NULL
150byte.
151Otherwise, \-1 is returned,
152the contents of the array are indeterminate,
153and
154.Va errno
155is set to indicate the error.
156.Sh ERRORS
157The
158.Fn strfmon
159function will fail if:
160.Bl -tag -width Er
161.It Bq Er E2BIG
162Conversion stopped due to lack of space in the buffer.
163.It Bq Er EINVAL
164The format string is invalid.
165.It Bq Er ENOMEM
166Not enough memory for temporary buffers.
167.El
168.Sh SEE ALSO
169.Xr localeconv 3 ,
170.Xr xlocale 3
171.Sh STANDARDS
172The
173.Fn strfmon
174function
175conforms to
176.St -p1003.1-2001 .
177.Sh AUTHORS
178.An -nosplit
179The
180.Fn strfmon
181function was implemented by
182.An Alexey Zelkin Aq phantom@FreeBSD.org .
183.Pp
184This manual page was written by
185.An Jeroen Ruigrok van der Werven Aq asmodai@FreeBSD.org
186based on the standards' text.
187.Sh BUGS
188The
189.Fn strfmon
190function does not correctly handle multibyte characters in the
191.Fa format
192argument.