2 .\" Copyright (c) 2000 Andries Brouwer (aeb@cwi.nl)
4 .\" SPDX-License-Identifier: GPL-2.0-or-later
6 .TH strfmon 3 (date) "Linux man-pages (unreleased)"
8 strfmon, strfmon_l \- convert monetary value to a string
11 .RI ( libc ", " \-lc )
14 .B #include <monetary.h>
16 .BI "ssize_t strfmon(char " s "[restrict ." max "], size_t " max ,
17 .BI " const char *restrict " format ", ...);"
18 .BI "ssize_t strfmon_l(char " s "[restrict ." max "], size_t " max ", \
20 .BI " const char *restrict " format ", ...);"
25 function formats the specified monetary amount
26 according to the current locale
27 and format specification
30 result in the character array
37 function performs the same task,
39 the locale specified by
45 is the special locale object
49 or is not a valid locale object handle.
51 Ordinary characters in
56 Conversion specifiers are introduced by a \[aq]%\[aq]
58 Immediately following it there can be zero or more
59 of the following flags:
62 The single-byte character
64 is used as the numeric fill character (to be used with
65 a left precision, see below).
66 When not specified, the space character is used.
69 Do not use any grouping characters that might be defined
70 for the current locale.
71 By default, grouping is enabled.
74 The ( flag indicates that negative amounts should be enclosed between
76 The + flag indicates that signs should be handled
77 in the default way, that is, amounts are preceded by the locale's
78 sign indication, for example, nothing for positive, "\-" for negative.
81 Omit the currency symbol.
84 Left justify all fields.
85 The default is right justification.
87 Next, there may be a field width: a decimal digit string specifying
88 a minimum field width in bytes.
90 A result smaller than this width is padded with spaces
91 (on the left, unless the left-justify flag was given).
93 Next, there may be a left precision of the form "#" followed by
94 a decimal digit string.
95 If the number of digits left of the
96 radix character is smaller than this, the representation is
97 padded on the left with the numeric fill character.
98 Grouping characters are not counted in this field width.
100 Next, there may be a right precision of the form "." followed by
101 a decimal digit string.
102 The amount being formatted is rounded to
103 the specified number of digits prior to formatting.
104 The default is specified in the
108 items of the current locale.
109 If the right precision is 0, no radix character is printed.
110 (The radix character here is determined by
112 and may differ from that specified by
115 Finally, the conversion specification must be ended with a
116 conversion character.
117 The three conversion characters are
120 (In this case, the entire specification must be exactly "%%".)
121 Put a \[aq]%\[aq] character in the result string.
126 is converted using the locale's international currency format.
131 is converted using the locale's national currency format.
135 function returns the number of characters placed
138 not including the terminating null byte,
139 provided the string, including the terminating null byte, fits.
144 returns \-1, and the contents of the array is undefined.
146 For an explanation of the terms used in this section, see
154 Interface Attribute Value
157 T} Thread safety MT-Safe locale
160 T} Thread safety MT-Safe
174 strfmon(buf, sizeof(buf), "[%\[ha]=*#6n] [%=*#6i]",
183 [€ **1234,57] [EUR **1 234,57]
200 [ **1234,57 €] [ **1.234,57 EUR]
201 [ Fr. **1234.57] [ CHF **1\[aq]234.57]
202 [ $**1234.57] [ AUD**1,234.57]
203 [ £**1234.57] [ GBP**1,234.57]