1STRFMON(3)                 Linux Programmer's Manual                STRFMON(3)
2
3
4

NAME

6       strfmon, strfmon_l - convert monetary value to a string
7

SYNOPSIS

9       #include <monetary.h>
10
11       ssize_t strfmon(char *s, size_t max, const char *format,
12       ...);
13
14       ssize_t strfmon_l(char *s, size_t max, locale_t locale,
15       const char *" format , ...);
16

DESCRIPTION

18       The  strfmon() function formats the specified monetary amount according
19       to the current locale and format specification format  and  places  the
20       result in the character array s of size max.
21
22       The  strfmon_l()  function  performs the same task, but uses the locale
23       specified by locale.  The  behavior  of  strfmon_l()  is  undefined  if
24       locale is the special locale object LC_GLOBAL_LOCALE (see duplocale(3))
25       or is not a valid locale object handle.
26
27       Ordinary characters in format are copied to s without conversion.  Con‐
28       version specifiers are introduced by a '%' character.  Immediately fol‐
29       lowing it there can be zero or more of the following flags:
30
31       =f     The single-byte character f is used as the numeric fill  charac‐
32              ter  (to  be  used  with a left precision, see below).  When not
33              specified, the space character is used.
34
35       ^      Do not use any grouping characters that might be defined for the
36              current locale.  By default, grouping is enabled.
37
38       ( or + The  (  flag  indicates that negative amounts should be enclosed
39              between parentheses.  The + flag indicates that signs should  be
40              handled in the default way, that is, amounts are preceded by the
41              locale's sign indication, for example, nothing for positive, "-"
42              for negative.
43
44       !      Omit the currency symbol.
45
46       -      Left justify all fields.  The default is right justification.
47
48       Next,  there  may be a field width: a decimal digit string specifying a
49       minimum field width in bytes.  The default is 0.  A result smaller than
50       this  width is padded with spaces (on the left, unless the left-justify
51       flag was given).
52
53       Next, there may be a left precision of the form "#" followed by a deci‐
54       mal  digit string.  If the number of digits left of the radix character
55       is smaller than this, the representation is padded on the left with the
56       numeric  fill  character.   Grouping characters are not counted in this
57       field width.
58
59       Next, there may be a right precision of the form "." followed by a dec‐
60       imal digit string.  The amount being formatted is rounded to the speci‐
61       fied number of digits prior to formatting.  The default is specified in
62       the  frac_digits  and  int_frac_digits items of the current locale.  If
63       the right precision is 0, no radix character is  printed.   (The  radix
64       character  here  is determined by LC_MONETARY, and may differ from that
65       specified by LC_NUMERIC.)
66
67       Finally, the conversion specification must be ended with  a  conversion
68       character.  The three conversion characters are
69
70       %      (In  this  case, the entire specification must be exactly "%%".)
71              Put a '%' character in the result string.
72
73       i      One argument of type double  is  converted  using  the  locale's
74              international currency format.
75
76       n      One  argument  of  type  double  is converted using the locale's
77              national currency format.
78

RETURN VALUE

80       The strfmon() function returns the number of characters placed  in  the
81       array  s, not including the terminating null byte, provided the string,
82       including the terminating null byte, fits.  Otherwise, it sets errno to
83       E2BIG, returns -1, and the contents of the array is undefined.
84

ATTRIBUTES

86       For   an   explanation   of   the  terms  used  in  this  section,  see
87       attributes(7).
88
89       ┌────────────┬───────────────┬────────────────┐
90Interface   Attribute     Value          
91       ├────────────┼───────────────┼────────────────┤
92strfmon()   │ Thread safety │ MT-Safe locale │
93       ├────────────┼───────────────┼────────────────┤
94strfmon_l() │ Thread safety │ MT-Safe        │
95       └────────────┴───────────────┴────────────────┘
96

CONFORMING TO

98       POSIX.1-2001, POSIX.1-2008.
99

EXAMPLE

101       The call
102
103           strfmon(buf, sizeof(buf), "[%^=*#6n] [%=*#6i]",
104                   1234.567, 1234.567);
105
106       outputs
107
108           [€ **1234,57] [EUR **1 234,57]
109
110       in the nl_NL locale.  The de_DE, de_CH, en_AU, and en_GB locales yield
111
112           [ **1234,57 €] [ **1.234,57 EUR]
113           [ Fr. **1234.57] [ CHF **1'234.57]
114           [ $**1234.57] [ AUD**1,234.57]
115           [ £**1234.57] [ GBP**1,234.57]
116

SEE ALSO

118       duplocale(3), setlocale(3), sprintf(3), locale(7)
119

COLOPHON

121       This page is part of release 4.15 of the Linux  man-pages  project.   A
122       description  of  the project, information about reporting bugs, and the
123       latest    version    of    this    page,    can     be     found     at
124       https://www.kernel.org/doc/man-pages/.
125
126
127
128Linux                             2017-09-15                        STRFMON(3)
Impressum