1 .\" Copyright (c) 2000 Andries Brouwer (aeb@cwi.nl)
3 .\" SPDX-License-Identifier: GPL-2.0-or-later
5 .TH STRFMON 3 2021-03-22 "Linux" "Linux Programmer's Manual"
7 strfmon, strfmon_l \- convert monetary value to a string
10 .RI ( libc ", " \-lc )
13 .B #include <monetary.h>
15 .BI "ssize_t strfmon(char *restrict " s ", size_t " max ,
16 .BI " const char *restrict " format ", ...);"
17 .BI "ssize_t strfmon_l(char *restrict " s ", size_t " max ", locale_t " locale ,
18 .BI " const char *restrict " format ", ...);"
23 function formats the specified monetary amount
24 according to the current locale
25 and format specification
28 result in the character array
35 function performs the same task,
37 the locale specified by
43 is the special locale object
47 or is not a valid locale object handle.
49 Ordinary characters in
54 Conversion specifiers are introduced by a \(aq%\(aq
56 Immediately following it there can be zero or more
57 of the following flags:
60 The single-byte character
62 is used as the numeric fill character (to be used with
63 a left precision, see below).
64 When not specified, the space character is used.
67 Do not use any grouping characters that might be defined
68 for the current locale.
69 By default, grouping is enabled.
72 The ( flag indicates that negative amounts should be enclosed between
74 The + flag indicates that signs should be handled
75 in the default way, that is, amounts are preceded by the locale's
76 sign indication, for example, nothing for positive, "\-" for negative.
79 Omit the currency symbol.
82 Left justify all fields.
83 The default is right justification.
85 Next, there may be a field width: a decimal digit string specifying
86 a minimum field width in bytes.
88 A result smaller than this width is padded with spaces
89 (on the left, unless the left-justify flag was given).
91 Next, there may be a left precision of the form "#" followed by
92 a decimal digit string.
93 If the number of digits left of the
94 radix character is smaller than this, the representation is
95 padded on the left with the numeric fill character.
96 Grouping characters are not counted in this field width.
98 Next, there may be a right precision of the form "." followed by
99 a decimal digit string.
100 The amount being formatted is rounded to
101 the specified number of digits prior to formatting.
102 The default is specified in the
106 items of the current locale.
107 If the right precision is 0, no radix character is printed.
108 (The radix character here is determined by
110 and may differ from that specified by
113 Finally, the conversion specification must be ended with a
114 conversion character.
115 The three conversion characters are
118 (In this case, the entire specification must be exactly "%%".)
119 Put a \(aq%\(aq character in the result string.
124 is converted using the locale's international currency format.
129 is converted using the locale's national currency format.
133 function returns the number of characters placed
136 not including the terminating null byte,
137 provided the string, including the terminating null byte, fits.
142 returns \-1, and the contents of the array is undefined.
144 For an explanation of the terms used in this section, see
152 Interface Attribute Value
155 T} Thread safety MT-Safe locale
158 T} Thread safety MT-Safe
164 POSIX.1-2001, POSIX.1-2008.
170 strfmon(buf, sizeof(buf), "[%\(ha=*#6n] [%=*#6i]",
179 [€ **1234,57] [EUR **1 234,57]
196 [ **1234,57 €] [ **1.234,57 EUR]
197 [ Fr. **1234.57] [ CHF **1\(aq234.57]
198 [ $**1234.57] [ AUD**1,234.57]
199 [ £**1234.57] [ GBP**1,234.57]