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

DESCRIPTION

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

RETURN VALUE

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

CONFORMING TO

77       Not in POSIX.1-2001.  Present on several other systems.
78

EXAMPLE

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

SEE ALSO

103       setlocale(3), sprintf(3), locale(7)
104

COLOPHON

106       This page is part of release 3.25 of the Linux  man-pages  project.   A
107       description  of  the project, and information about reporting bugs, can
108       be found at http://www.kernel.org/doc/man-pages/.
109
110
111
112Linux                             2000-12-05                        STRFMON(3)
Impressum