OSDN Git Service

f38f5cc8eab5bc98a8ebaec051324f1fd4d8ac3a
[linuxjm/LDP_man-pages.git] / draft / man3 / strfmon.3
1 .\" Copyright (c) 2000 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" The GNU General Public License's references to "object code"
9 .\" and "executables" are to be interpreted as the output of any
10 .\" document formatting or typesetting system, including
11 .\" intermediate and printed output.
12 .\"
13 .\" This manual is distributed in the hope that it will be useful,
14 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 .\" GNU General Public License for more details.
17 .\"
18 .\" You should have received a copy of the GNU General Public
19 .\" License along with this manual; if not, write to the Free
20 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
21 .\" USA.
22 .\"
23 .\" Japanese Version Copyright (c) 2001 NAKANO Takeo all rights reserved.
24 .\" Translated Thu Fri 08 2001 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
25 .\"
26 .\"WORD:        numeric fill character  数値埋め文字
27 .\"WORD:        grouping character      グループ化文字
28 .\"WORD:        left precision          左精度
29 .\"WORD:        right precision         左精度
30 .\"WORD:        radix (character)       基数点(文字)
31 .\"WORD:        conversion character    変換文字
32 .\"WORD:        international currency format   国際通貨フォーマット
33 .\"WORD:        national currency format        国内通貨フォーマット
34 .\"
35 .TH STRFMON 3 2000-12-05 "Linux" "Linux Programmer's Manual"
36 .\"O .SH NAME
37 .\"O strfmon \- convert monetary value to a string
38 .SH 名前
39 strfmon \- 金額の値を文字列に変換する
40 .\"O .SH SYNOPSIS
41 .SH 書式
42 .B #include <monetary.h>
43 .sp
44 .BI "ssize_t strfmon(char *" s ", size_t " max ", const char *" format ,
45 .B "...);"
46 .\"O .SH DESCRIPTION
47 .SH 説明
48 .\"O The
49 .\"O .BR strfmon ()
50 .\"O function formats the specified amounts
51 .\"O according to the format specification \fIformat\fP and places the
52 .\"O result in the character array \fIs\fP of size \fImax\fP.
53 .BR strfmon ()
54 関数は、指定された数量を
55 .I format
56 で指定されたフォーマットにしたがって整形し、
57 結果をサイズ
58 .I max
59 の文字配列
60 .I s
61 に書きこむ。
62 .PP
63 .\"O Ordinary characters in \fIformat\fP are copied to \fIs\fP
64 .\"O without conversion.
65 .\"O Conversion specifiers are introduced by a \(aq%\(aq
66 .\"O character.
67 .\"O Immediately following it there can be zero or more
68 .\"O of the following flags:
69 .I format
70 中の通常の文字は、変換されずにそのまま
71 .I s
72 にコピーされる。変換指定は \(aq%\(aq 文字で始まる。
73 この直後には、以下のフラグを 0 個以上続けることができる。
74 .TP
75 .BI = f
76 .\"O The single-byte character
77 .\"O .I f
78 .\"O is used as the numeric fill character (to be used with
79 .\"O a left precision, see below).
80 .\"O When not specified, the space character is used.
81 1 バイト文字
82 .I f
83 を数値埋め文字 (numeric fill character) にする
84 (左精度と共に用いる。以下を参照)。
85 指定されないと、スペース文字が用いられる。
86 .TP
87 .B ^
88 .\"O Do not use any grouping characters that might be defined
89 .\"O for the current locale.
90 .\"O By default, grouping is enabled.
91 現在のロケールで定義されているであろうグループ化文字 (grouping character)
92 を一切使わない。デフォルトではグループ化は有効になっている。
93 .TP
94 .\"O .BR ( " or " +
95 .BR ( " または " +
96 .\"O The ( flag indicates that negative amounts should be enclosed between
97 .\"O parentheses.
98 .\"O The + flag indicates that signs should be handled
99 .\"O in the default way, that is, amounts are preceded by the locale's
100 .\"O sign indication, for example, nothing for positive, "\-" for negative.
101 ( フラグは、負の数値を括弧で括ることを意味する。
102 + フラグは符号をデフォルトのように取り扱うことを意味する
103 (すなわち数値の前にロケールの符号マークが置かれる。
104 例えば正ならなにもなく、負なら \(aq\-\(aq を置く、など)。
105 .TP
106 .B !
107 .\"O Omit the currency symbol.
108 通貨シンボルを省略する。
109 .TP
110 .B \-
111 .\"O Left justify all fields.
112 .\"O The default is right justification.
113 すべてのフィールドを左詰めにする。デフォルトは右詰め。
114 .LP
115 .\"O Next, there may be a field width: a decimal digit string specifying
116 .\"O a minimum field width in bytes.
117 .\"O The default is 0.
118 .\"O A result smaller than this width is padded with spaces
119 .\"O (on the left, unless the left-justify flag was given).
120 次の位置には、フィールドの幅を指定できる。
121 10 進の数値文字列で、フィールドの最小幅をバイト単位で指定する。
122 デフォルトは 0。
123 結果がこの幅よりも狭くなった場合には、
124 不足分がスペースで埋められる
125 (左詰めフラグが指定されていなければ左側が埋められる)。
126 .LP
127 .\"O Next, there may be a left precision of the form "#" followed by
128 .\"O a decimal digit string.
129 .\"O If the number of digits left of the
130 .\"O radix character is smaller than this, the representation is
131 .\"O padded on the left with the numeric fill character.
132 .\"O Grouping characters are not counted in this field width.
133 次の位置には、"#" に 10 進数値文字列を続けた形式で、
134 左精度 (left precision) を指定できる。
135 通貨の基数点 (radix) より左側の数値の桁数がこの指定より小さい場合は、
136 数値埋め文字で左側が埋められる。
137 このフィールド幅の指定では、グループ化文字はカウントされない。
138 .LP
139 .\"O Next, there may be a right precision of the form "." followed by
140 .\"O a decimal digit string.
141 .\"O The amount being formatted is rounded to
142 .\"O the specified number of digits prior to formatting.
143 .\"O The default is specified in the
144 .\"O .I frac_digits
145 .\"O and
146 .\"O .I int_frac_digits
147 .\"O items of the current locale.
148 .\"O If the right precision is 0, no radix character is printed.
149 .\"O (The radix character here is determined by
150 .\"O .BR LC_MONETARY ,
151 .\"O and may differ from that specified by
152 .\"O .BR LC_NUMERIC .)
153 次の位置には、"." に 10 進数値文字列を続けた形式で、
154 右精度 (right precision) を指定できる。
155 整形される数値は、整形前にこの桁数に丸められる。
156 デフォルトではカレントロケールの
157 .I frac_digits
158
159 .I int_frac_digits
160 の指定を用いる。
161 右精度が 0 の場合は、基数点文字 (radix character) は印字されない
162 (ここでの基数点文字は
163 .B LC_MONETARY
164 で定義されており、
165 .B LC_NUMERIC
166 の指定とは異なっていてもよい)。
167 .LP
168 .\"O Finally, the conversion specification must be ended with a
169 .\"O conversion character.
170 .\"O The three conversion characters are
171 最後に、変換指定は変換文字 (conversion character)
172 で終了しなければならない。
173 変換文字には以下の 3 つがある。
174 .TP
175 .B %
176 .\"O (In this case the entire specification must be exactly "%%".)
177 .\"O Put a \(aq%\(aq character in the result string.
178 (この場合は指定全体が "%%" でなければならない。)
179 結果の文字列に \(aq%\(aq 文字を書きこむ。
180 .TP
181 .B i
182 .\"O One argument of type
183 .\"O .I double
184 .\"O is converted using the locale's international currency format.
185 .I double
186 型の引き数ひとつが、
187 ロケールの国際通貨フォーマット (international currency format)
188 を用いて変換される。
189 .TP
190 .B n
191 .\"O One argument of type
192 .\"O .I double
193 .\"O is converted using the locale's national currency format.
194 .I double
195 型の引き数ひとつが、
196 ロケールの国内通貨フォーマット (national currency format)
197 を用いて変換される。
198 .\"O .SH "RETURN VALUE"
199 .SH 返り値
200 .\"O The
201 .\"O .BR strfmon ()
202 .\"O function returns the number of characters placed
203 .\"O in the array \fIs\fP, not including the terminating null byte,
204 .\"O provided the string, including the terminating null byte, fits.
205 .\"O Otherwise, it sets
206 .\"O .I errno
207 .\"O to
208 .\"O .BR E2BIG ,
209 .\"O returns \-1, and the contents of the array is undefined.
210 .BR strfmon ()
211 関数は、結果の文字列が終端の NULL バイトを含めて配列
212 .I s
213 に収まった場合には、
214 .I s
215 に書きこまれた文字数を返す。NULL バイトは文字数に入らない。
216 それ以外の場合には、
217 .I errno
218
219 .B E2BIG
220 を設定して \-1 を返す。
221 この場合の配列の内容は未定義である。
222 .\"O .SH "CONFORMING TO"
223 .SH 準拠
224 .\"O Not in POSIX.1-2001.
225 .\"O Present on several other systems.
226 POSIX.1-2001 にはない。
227 他のいくつかのシステムに存在する。
228 .\"O .SH EXAMPLE
229 .SH 例
230 .\"O The call
231 .in +4n
232 .nf
233
234 strfmon(buf, sizeof(buf), "[%^=*#6n] [%=*#6i]",
235         1234.567, 1234.567);
236
237 .fi
238 .in
239 のような関数コールの出力は、オランダのロケールでは以下のような出力になる。
240 .\"O outputs
241 .in +4n
242
243 [ fl **1234,57] [ NLG  **1 234,57]
244
245 .in
246 .\"O in the Dutch locale (with fl for "florijnen" and NLG for Netherlands Guilders).
247 (fl は "florijnen" の意。NLG は Netherlands Guilder。)
248 .\"O The grouping character is very ugly because it takes as much space
249 .\"O as a digit, while it should not take more than half that,
250 .\"O and will no doubt cause confusion.
251 .\"O Surprisingly, the "fl" is preceded and followed by a space,
252 .\"O and "NLG" is preceded by one and followed by two spaces.
253 .\"O This may be a bug in the locale files.
254 .\"O The Italian, Australian, Swiss
255 .\"O and Portuguese locales yield
256 グループ化文字を用いると非常に醜くなる。
257 同時に間違いなく混乱の原因にもなってしまうだろう。
258 これは数値の半分以下の幅であるべきだが、
259 数値と同じだけの幅を取ってしまうからである。
260 ひどいことに、 "fl" の前後にはスペースが入ってしまい、
261 また "NLG" の前には 1 つ、後には 2 つのスペースが置かれている。
262 これはロケールファイルのバグであろう。
263 イタリア・オーストラリア・スイス・ポルトガルの
264 各ロケールでの結果は以下のようになる。
265 .in +4n
266
267 [ L. **1235] [ ITL  **1.235]
268 .br
269 [ $**1234.57] [ AUD **1,234.57]
270 .br
271 [Fr. **1234,57] [CHF  **1.234,57]
272 .br
273 [ **1234$57Esc] [ **1.234$57PTE ]
274 .in
275 .\"O .SH "SEE ALSO"
276 .SH 関連項目
277 .BR setlocale (3),
278 .BR sprintf (3),
279 .BR locale (7)