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

NAME

6       strfmon - 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

DESCRIPTION

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

RETURN VALUE

72       The  strfmon()  function returns the number of characters placed in the
73       array s, not including the terminating null byte, provided the  string,
74       including the terminating null byte, fits.  Otherwise, it sets errno to
75       E2BIG, returns -1, and the contents of the array is undefined.
76

EXAMPLE

78       The call
79              strfmon(buf, sizeof(buf), "[%^=*#6n] [%=*#6i]",
80                      1234.567, 1234.567);
81       outputs
82              [ fl **1234,57] [ NLG  **1 234,57]
83       in the Dutch locale (with fl for "florijnen" and  NLG  for  Netherlands
84       Guilders).   The  grouping  character  is very ugly because it takes as
85       much space as a digit, while it should not take more  than  half  that,
86       and  will no doubt cause confusion.  Surprisingly, the "fl" is preceded
87       and followed by a space, and "NLG" is preceded by one and  followed  by
88       two  spaces.   This may be a bug in the locale files. The Italian, Aus‐
89       tralian, Swiss and Portuguese locales yield
90              [ L. **1235] [ ITL  **1.235]
91              [ $**1234.57] [ AUD **1,234.57]
92              [Fr. **1234,57] [CHF  **1.234,57]
93              [ **1234$57Esc] [ **1.234$57PTE ]
94

CONFORMING TO

96       Not in POSIX.1-2001.  Present on several other systems.
97

SEE ALSO

99       setlocale(3), sprintf(3), locale(7)
100
101
102
103Linux                             2000-12-05                        STRFMON(3)
Impressum