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