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