xref: /dragonfly/lib/libc/stdlib/strfmon.3 (revision 99dd49c5)
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.\" $NetBSD: strfmon.3,v 1.3 2005/04/04 08:19:00 wiz Exp $
27.\" $DragonFly: src/lib/libc/stdlib/strfmon.3,v 1.1 2008/10/06 21:01:37 swildner Exp $
28.\"
29.Dd October 6, 2008
30.Dt STRFMON 3
31.Os
32.Sh NAME
33.Nm strfmon
34.Nd convert monetary value to string
35.Sh LIBRARY
36.Lb libc
37.Sh SYNOPSIS
38.In monetary.h
39.Ft ssize_t
40.Fn strfmon "char * restrict s" "size_t maxsize" "const char * restrict format" "..."
41.Sh DESCRIPTION
42The
43.Fn strfmon
44function places characters into the array pointed to by
45.Fa s
46as controlled by the string pointed to by
47.Fa format .
48No more than
49.Fa maxsize
50bytes are placed into the array.
51.Pp
52The format string is composed of zero or more directives:
53ordinary characters (not
54.Cm % ) ,
55which are copied unchanged to the output stream; and conversion
56specifications, each of which results in fetching zero or more subsequent
57arguments.
58Each conversion specification is introduced by the
59.Cm %
60character.
61After the
62.Cm % ,
63the following appear in sequence:
64.Bl -bullet
65.It
66Zero or more of the following flags:
67.Bl -tag -width "XXX"
68.It Cm = Ns Ar f
69A
70.Sq Cm =
71character followed by another character
72.Ar f
73which is used as the numeric fill character.
74.It Cm ^
75Do not use grouping characters, regardless of the current locale default.
76.It Cm +
77Represent positive values by prefixing them with a positive sign,
78and negative values by prefixing them with a negative sign.
79This is the default.
80.It Cm \&(
81Enclose negative values in parentheses.
82.It Cm \&!
83Do not include a currency symbol in the output.
84.It Cm \-
85Left justify the result.
86Only valid when a field width is specified.
87.El
88.It
89An optional minimum field width as a decimal number.
90By default, there is no minimum width.
91.It
92A
93.Sq Cm #
94sign followed by a decimal number specifying the maximum
95expected number of digits after the radix character.
96.It
97A
98.Sq Cm \&.
99character followed by a decimal number specifying the number
100of digits after the radix character.
101.It
102One of the following conversion specifiers:
103.Bl -tag -width "XXX"
104.It Cm i
105The
106.Vt double
107argument is formatted as an international monetary amount.
108.It Cm n
109The
110.Vt double
111argument is formatted as a national monetary amount.
112.It Cm %
113A
114.Sq Li %
115character is written.
116.El
117.El
118.Sh RETURN VALUES
119If the total number of resulting bytes including the terminating
120.Dv NULL
121byte is not more than
122.Fa maxsize ,
123.Fn strfmon
124returns the number of bytes placed into the array pointed to by
125.Fa s ,
126not including the terminating
127.Dv NULL
128byte.
129Otherwise, \-1 is returned,
130the contents of the array are indeterminate,
131and
132.Va errno
133is set to indicate the error.
134.Sh ERRORS
135The
136.Fn strfmon
137function will fail if:
138.Bl -tag -width Er
139.It Bq Er E2BIG
140Conversion stopped due to lack of space in the buffer.
141.It Bq Er EINVAL
142The format string is invalid.
143.It Bq Er ENOMEM
144Not enough memory for temporary buffers.
145.El
146.Sh SEE ALSO
147.Xr localeconv 3
148.Sh STANDARDS
149The
150.Fn strfmon
151function
152conforms to
153.St -p1003.1-2001 .
154.Sh AUTHORS
155.An -nosplit
156The
157.Fn strfmon
158function was implemented by
159.An Alexey Zelkin Aq phantom@FreeBSD.org .
160.Pp
161This manual page was written by
162.An Jeroen Ruigrok van der Werven Aq asmodai@FreeBSD.org
163based on the standard's text.
164.Sh BUGS
165The
166.Fn strfmon
167function does not correctly handle multibyte characters in the
168.Fa format
169argument.
170