]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/strfmon.3
getent.1, intro.1, time.1, _exit.2, _syscall.2, accept.2, access.2, acct.2, adjtimex...
[thirdparty/man-pages.git] / man3 / strfmon.3
CommitLineData
fea681da
MK
1.\" Copyright (c) 2000 Andries Brouwer (aeb@cwi.nl)
2.\"
3.\" This is free documentation; you can redistribute it and/or
4.\" modify it under the terms of the GNU General Public License as
5.\" published by the Free Software Foundation; either version 2 of
6.\" the License, or (at your option) any later version.
7.\"
8.\" The GNU General Public License's references to "object code"
9.\" and "executables" are to be interpreted as the output of any
10.\" document formatting or typesetting system, including
11.\" intermediate and printed output.
12.\"
13.\" This manual is distributed in the hope that it will be useful,
14.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16.\" GNU General Public License for more details.
17.\"
18.\" You should have received a copy of the GNU General Public
19.\" License along with this manual; if not, write to the Free
20.\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
21.\" USA.
22.\"
23.TH STRFMON 3 2000-12-05 "Linux" "Linux Programmer's Manual"
24.SH NAME
25strfmon \- convert monetary value to a string
26.SH SYNOPSIS
fea681da
MK
27.B #include <monetary.h>
28.sp
29.BI "ssize_t strfmon(char *" s ", size_t " max ", const char *" format ,
30.B "...);"
fea681da 31.SH DESCRIPTION
60a90ecd
MK
32The
33.BR strfmon ()
34function formats the specified amounts
fea681da
MK
35according to the format specification \fIformat\fP and places the
36result in the character array \fIs\fP of size \fImax\fP.
37.PP
38Ordinary characters in \fIformat\fP are copied to \fIs\fP
c13182ef 39without conversion.
f81fb444 40Conversion specifiers are introduced by a \(aq%\(aq
c13182ef
MK
41character.
42Immediately following it there can be zero or more
fea681da
MK
43of the following flags:
44.TP
45.BI = f
46The single-byte character
47.I f
48is used as the numeric fill character (to be used with
49a left precision, see below).
50When not specified, the space character is used.
51.TP
52.B ^
53Do not use any grouping characters that might be defined
c13182ef
MK
54for the current locale.
55By default, grouping is enabled.
fea681da
MK
56.TP
57.BR ( " or " +
58The ( flag indicates that negative amounts should be enclosed between
c13182ef
MK
59parentheses.
60The + flag indicates that signs should be handled
fea681da 61in the default way, that is, amounts are preceded by the locale's
75b94dc3 62sign indication, for example, nothing for positive, "\-" for negative.
fea681da 63.TP
0daa9e92 64.B !
fea681da
MK
65Omit the currency symbol.
66.TP
0daa9e92 67.B \-
c13182ef
MK
68Left justify all fields.
69The default is right justification.
fea681da
MK
70.LP
71Next, there may be a field width: a decimal digit string specifying
c13182ef
MK
72a minimum field width in bytes.
73The default is 0.
fea681da
MK
74A result smaller than this width is padded with spaces
75(on the left, unless the left-justify flag was given).
76.LP
77Next, there may be a left precision of the form "#" followed by
c13182ef
MK
78a decimal digit string.
79If the number of digits left of the
fea681da
MK
80radix character is smaller than this, the representation is
81padded on the left with the numeric fill character.
82Grouping characters are not counted in this field width.
83.LP
84Next, there may be a right precision of the form "." followed by
c13182ef
MK
85a decimal digit string.
86The amount being formatted is rounded to
fea681da
MK
87the specified number of digits prior to formatting.
88The default is specified in the
89.I frac_digits
90and
91.I int_frac_digits
92items of the current locale.
93If the right precision is 0, no radix character is printed.
097585ed 94(The radix character here is determined by
74d32233 95.BR LC_MONETARY ,
097585ed
MK
96and may differ from that specified by
97.BR LC_NUMERIC .)
fea681da
MK
98.LP
99Finally, the conversion specification must be ended with a
c13182ef
MK
100conversion character.
101The three conversion characters are
fea681da
MK
102.TP
103.B %
104(In this case the entire specification must be exactly "%%".)
f81fb444 105Put a \(aq%\(aq character in the result string.
fea681da
MK
106.TP
107.B i
6d275e3c
MK
108One argument of type
109.I double
110is converted using the locale's international currency format.
fea681da
MK
111.TP
112.B n
6d275e3c
MK
113One argument of type
114.I double
115is converted using the locale's national currency format.
47297adb 116.SH RETURN VALUE
60a90ecd
MK
117The
118.BR strfmon ()
119function returns the number of characters placed
28d88c17
MK
120in the array \fIs\fP, not including the terminating null byte,
121provided the string, including the terminating null byte, fits.
fea681da
MK
122Otherwise, it sets
123.I errno
097585ed
MK
124to
125.BR E2BIG ,
126returns \-1, and the contents of the array is undefined.
47297adb 127.SH CONFORMING TO
2b2581ee
MK
128Not in POSIX.1-2001.
129Present on several other systems.
fea681da
MK
130.SH EXAMPLE
131The call
a6e2f128 132.in +4n
fea681da 133.nf
b9f02710 134
fea681da
MK
135strfmon(buf, sizeof(buf), "[%^=*#6n] [%=*#6i]",
136 1234.567, 1234.567);
b9f02710 137
fea681da 138.fi
a6e2f128 139.in
fea681da 140outputs
a6e2f128 141.in +4n
b9f02710 142
fea681da 143[ fl **1234,57] [ NLG **1 234,57]
b9f02710 144
a6e2f128 145.in
fea681da
MK
146in the Dutch locale (with fl for "florijnen" and NLG for Netherlands Guilders).
147The grouping character is very ugly because it takes as much space
148as a digit, while it should not take more than half that,
149and will no doubt cause confusion.
150Surprisingly, the "fl" is preceded and followed by a space,
151and "NLG" is preceded by one and followed by two spaces.
c13182ef
MK
152This may be a bug in the locale files.
153The Italian, Australian, Swiss
fea681da 154and Portuguese locales yield
a6e2f128 155.in +4n
b9f02710 156
fea681da
MK
157[ L. **1235] [ ITL **1.235]
158.br
159[ $**1234.57] [ AUD **1,234.57]
160.br
161[Fr. **1234,57] [CHF **1.234,57]
162.br
163[ **1234$57Esc] [ **1.234$57PTE ]
a6e2f128 164.in
47297adb 165.SH SEE ALSO
fea681da
MK
166.BR setlocale (3),
167.BR sprintf (3),
168.BR locale (7)