]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) 2000 Andries Brouwer (aeb@cwi.nl) |
2 | .\" | |
1dd72f9c | 3 | .\" %%%LICENSE_START(GPLv2+_DOC_FULL) |
fea681da MK |
4 | .\" This is free documentation; you can redistribute it and/or |
5 | .\" modify it under the terms of the GNU General Public License as | |
6 | .\" published by the Free Software Foundation; either version 2 of | |
7 | .\" the License, or (at your option) any later version. | |
8 | .\" | |
9 | .\" The GNU General Public License's references to "object code" | |
10 | .\" and "executables" are to be interpreted as the output of any | |
11 | .\" document formatting or typesetting system, including | |
12 | .\" intermediate and printed output. | |
13 | .\" | |
14 | .\" This manual is distributed in the hope that it will be useful, | |
15 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | .\" GNU General Public License for more details. | |
18 | .\" | |
19 | .\" You should have received a copy of the GNU General Public | |
c715f741 MK |
20 | .\" License along with this manual; if not, see |
21 | .\" <http://www.gnu.org/licenses/>. | |
6a8d8745 | 22 | .\" %%%LICENSE_END |
fea681da MK |
23 | .\" |
24 | .TH STRFMON 3 2000-12-05 "Linux" "Linux Programmer's Manual" | |
25 | .SH NAME | |
26 | strfmon \- convert monetary value to a string | |
27 | .SH SYNOPSIS | |
fea681da MK |
28 | .B #include <monetary.h> |
29 | .sp | |
30 | .BI "ssize_t strfmon(char *" s ", size_t " max ", const char *" format , | |
31 | .B "...);" | |
fea681da | 32 | .SH DESCRIPTION |
60a90ecd MK |
33 | The |
34 | .BR strfmon () | |
35 | function formats the specified amounts | |
c6fa0841 MK |
36 | according to the format specification |
37 | .I format | |
38 | and places the | |
39 | result in the character array | |
40 | .I s | |
41 | of size | |
42 | .IR max . | |
fea681da | 43 | .PP |
c6fa0841 MK |
44 | Ordinary characters in |
45 | .I format | |
46 | are copied to | |
47 | .I s | |
c13182ef | 48 | without conversion. |
f81fb444 | 49 | Conversion specifiers are introduced by a \(aq%\(aq |
c13182ef MK |
50 | character. |
51 | Immediately following it there can be zero or more | |
fea681da MK |
52 | of the following flags: |
53 | .TP | |
54 | .BI = f | |
55 | The single-byte character | |
56 | .I f | |
57 | is used as the numeric fill character (to be used with | |
58 | a left precision, see below). | |
59 | When not specified, the space character is used. | |
60 | .TP | |
61 | .B ^ | |
62 | Do not use any grouping characters that might be defined | |
c13182ef MK |
63 | for the current locale. |
64 | By default, grouping is enabled. | |
fea681da MK |
65 | .TP |
66 | .BR ( " or " + | |
67 | The ( flag indicates that negative amounts should be enclosed between | |
c13182ef MK |
68 | parentheses. |
69 | The + flag indicates that signs should be handled | |
fea681da | 70 | in the default way, that is, amounts are preceded by the locale's |
75b94dc3 | 71 | sign indication, for example, nothing for positive, "\-" for negative. |
fea681da | 72 | .TP |
0daa9e92 | 73 | .B ! |
fea681da MK |
74 | Omit the currency symbol. |
75 | .TP | |
0daa9e92 | 76 | .B \- |
c13182ef MK |
77 | Left justify all fields. |
78 | The default is right justification. | |
fea681da MK |
79 | .LP |
80 | Next, there may be a field width: a decimal digit string specifying | |
c13182ef MK |
81 | a minimum field width in bytes. |
82 | The default is 0. | |
fea681da MK |
83 | A result smaller than this width is padded with spaces |
84 | (on the left, unless the left-justify flag was given). | |
85 | .LP | |
86 | Next, there may be a left precision of the form "#" followed by | |
c13182ef MK |
87 | a decimal digit string. |
88 | If the number of digits left of the | |
fea681da MK |
89 | radix character is smaller than this, the representation is |
90 | padded on the left with the numeric fill character. | |
91 | Grouping characters are not counted in this field width. | |
92 | .LP | |
93 | Next, there may be a right precision of the form "." followed by | |
c13182ef MK |
94 | a decimal digit string. |
95 | The amount being formatted is rounded to | |
fea681da MK |
96 | the specified number of digits prior to formatting. |
97 | The default is specified in the | |
98 | .I frac_digits | |
99 | and | |
100 | .I int_frac_digits | |
101 | items of the current locale. | |
102 | If the right precision is 0, no radix character is printed. | |
097585ed | 103 | (The radix character here is determined by |
74d32233 | 104 | .BR LC_MONETARY , |
097585ed MK |
105 | and may differ from that specified by |
106 | .BR LC_NUMERIC .) | |
fea681da MK |
107 | .LP |
108 | Finally, the conversion specification must be ended with a | |
c13182ef MK |
109 | conversion character. |
110 | The three conversion characters are | |
fea681da MK |
111 | .TP |
112 | .B % | |
113 | (In this case the entire specification must be exactly "%%".) | |
f81fb444 | 114 | Put a \(aq%\(aq character in the result string. |
fea681da MK |
115 | .TP |
116 | .B i | |
6d275e3c MK |
117 | One argument of type |
118 | .I double | |
119 | is converted using the locale's international currency format. | |
fea681da MK |
120 | .TP |
121 | .B n | |
6d275e3c MK |
122 | One argument of type |
123 | .I double | |
124 | is converted using the locale's national currency format. | |
47297adb | 125 | .SH RETURN VALUE |
60a90ecd MK |
126 | The |
127 | .BR strfmon () | |
128 | function returns the number of characters placed | |
c6fa0841 MK |
129 | in the array |
130 | .IR s , | |
131 | not including the terminating null byte, | |
28d88c17 | 132 | provided the string, including the terminating null byte, fits. |
fea681da MK |
133 | Otherwise, it sets |
134 | .I errno | |
097585ed MK |
135 | to |
136 | .BR E2BIG , | |
137 | returns \-1, and the contents of the array is undefined. | |
47297adb | 138 | .SH CONFORMING TO |
2b2581ee MK |
139 | Not in POSIX.1-2001. |
140 | Present on several other systems. | |
fea681da MK |
141 | .SH EXAMPLE |
142 | The call | |
a6e2f128 | 143 | .in +4n |
fea681da | 144 | .nf |
b9f02710 | 145 | |
fea681da MK |
146 | strfmon(buf, sizeof(buf), "[%^=*#6n] [%=*#6i]", |
147 | 1234.567, 1234.567); | |
b9f02710 | 148 | |
fea681da | 149 | .fi |
a6e2f128 | 150 | .in |
fea681da | 151 | outputs |
a6e2f128 | 152 | .in +4n |
b9f02710 | 153 | |
fea681da | 154 | [ fl **1234,57] [ NLG **1 234,57] |
b9f02710 | 155 | |
a6e2f128 | 156 | .in |
fea681da MK |
157 | in the Dutch locale (with fl for "florijnen" and NLG for Netherlands Guilders). |
158 | The grouping character is very ugly because it takes as much space | |
159 | as a digit, while it should not take more than half that, | |
160 | and will no doubt cause confusion. | |
161 | Surprisingly, the "fl" is preceded and followed by a space, | |
162 | and "NLG" is preceded by one and followed by two spaces. | |
c13182ef MK |
163 | This may be a bug in the locale files. |
164 | The Italian, Australian, Swiss | |
fea681da | 165 | and Portuguese locales yield |
a6e2f128 | 166 | .in +4n |
b9f02710 | 167 | |
fea681da MK |
168 | [ L. **1235] [ ITL **1.235] |
169 | .br | |
170 | [ $**1234.57] [ AUD **1,234.57] | |
171 | .br | |
172 | [Fr. **1234,57] [CHF **1.234,57] | |
173 | .br | |
174 | [ **1234$57Esc] [ **1.234$57PTE ] | |
a6e2f128 | 175 | .in |
47297adb | 176 | .SH SEE ALSO |
fea681da MK |
177 | .BR setlocale (3), |
178 | .BR sprintf (3), | |
179 | .BR locale (7) |