.\" Copyright (c) 2000 Andries Brouwer (aeb@cwi.nl) .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, write to the Free .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, .\" USA. .\" .\" Japanese Version Copyright (c) 2001 NAKANO Takeo all rights reserved. .\" Translated Thu Fri 08 2001 by NAKANO Takeo .\" .\"WORD: numeric fill character 数値埋め文字 .\"WORD: grouping character グループ化文字 .\"WORD: left precision 左精度 .\"WORD: right precision 左精度 .\"WORD: radix (character) 基数点(文字) .\"WORD: conversion character 変換文字 .\"WORD: international currency format 国際通貨フォーマット .\"WORD: national currency format 国内通貨フォーマット .\" .TH STRFMON 3 2000-12-05 "Linux" "Linux Programmer's Manual" .\"O .SH NAME .\"O strfmon \- convert monetary value to a string .SH 名前 strfmon \- 金額の値を文字列に変換する .\"O .SH SYNOPSIS .SH 書式 .B #include .sp .BI "ssize_t strfmon(char *" s ", size_t " max ", const char *" format , .B "...);" .\"O .SH DESCRIPTION .SH 説明 .\"O The .\"O .BR strfmon () .\"O function formats the specified amounts .\"O according to the format specification \fIformat\fP and places the .\"O result in the character array \fIs\fP of size \fImax\fP. .BR strfmon () 関数は、指定された数量を .I format で指定されたフォーマットにしたがって整形し、 結果をサイズ .I max の文字配列 .I s に書きこむ。 .PP .\"O Ordinary characters in \fIformat\fP are copied to \fIs\fP .\"O without conversion. .\"O Conversion specifiers are introduced by a \(aq%\(aq .\"O character. .\"O Immediately following it there can be zero or more .\"O of the following flags: .I format 中の通常の文字は、変換されずにそのまま .I s にコピーされる。変換指定は \(aq%\(aq 文字で始まる。 この直後には、以下のフラグを 0 個以上続けることができる。 .TP .BI = f .\"O The single-byte character .\"O .I f .\"O is used as the numeric fill character (to be used with .\"O a left precision, see below). .\"O When not specified, the space character is used. 1 バイト文字 .I f を数値埋め文字 (numeric fill character) にする (左精度と共に用いる。以下を参照)。 指定されないと、スペース文字が用いられる。 .TP .B ^ .\"O Do not use any grouping characters that might be defined .\"O for the current locale. .\"O By default, grouping is enabled. 現在のロケールで定義されているであろうグループ化文字 (grouping character) を一切使わない。デフォルトではグループ化は有効になっている。 .TP .\"O .BR ( " or " + .BR ( " または " + .\"O The ( flag indicates that negative amounts should be enclosed between .\"O parentheses. .\"O The + flag indicates that signs should be handled .\"O in the default way, that is, amounts are preceded by the locale's .\"O sign indication, for example, nothing for positive, "\-" for negative. ( フラグは、負の数値を括弧で括ることを意味する。 + フラグは符号をデフォルトのように取り扱うことを意味する (すなわち数値の前にロケールの符号マークが置かれる。 例えば正ならなにもなく、負なら \(aq\-\(aq を置く、など)。 .TP .B ! .\"O Omit the currency symbol. 通貨シンボルを省略する。 .TP .B \- .\"O Left justify all fields. .\"O The default is right justification. すべてのフィールドを左詰めにする。デフォルトは右詰め。 .LP .\"O Next, there may be a field width: a decimal digit string specifying .\"O a minimum field width in bytes. .\"O The default is 0. .\"O A result smaller than this width is padded with spaces .\"O (on the left, unless the left-justify flag was given). 次の位置には、フィールドの幅を指定できる。 10 進の数値文字列で、フィールドの最小幅をバイト単位で指定する。 デフォルトは 0。 結果がこの幅よりも狭くなった場合には、 不足分がスペースで埋められる (左詰めフラグが指定されていなければ左側が埋められる)。 .LP .\"O Next, there may be a left precision of the form "#" followed by .\"O a decimal digit string. .\"O If the number of digits left of the .\"O radix character is smaller than this, the representation is .\"O padded on the left with the numeric fill character. .\"O Grouping characters are not counted in this field width. 次の位置には、"#" に 10 進数値文字列を続けた形式で、 左精度 (left precision) を指定できる。 通貨の基数点 (radix) より左側の数値の桁数がこの指定より小さい場合は、 数値埋め文字で左側が埋められる。 このフィールド幅の指定では、グループ化文字はカウントされない。 .LP .\"O Next, there may be a right precision of the form "." followed by .\"O a decimal digit string. .\"O The amount being formatted is rounded to .\"O the specified number of digits prior to formatting. .\"O The default is specified in the .\"O .I frac_digits .\"O and .\"O .I int_frac_digits .\"O items of the current locale. .\"O If the right precision is 0, no radix character is printed. .\"O (The radix character here is determined by .\"O .BR LC_MONETARY , .\"O and may differ from that specified by .\"O .BR LC_NUMERIC .) 次の位置には、"." に 10 進数値文字列を続けた形式で、 右精度 (right precision) を指定できる。 整形される数値は、整形前にこの桁数に丸められる。 デフォルトではカレントロケールの .I frac_digits と .I int_frac_digits の指定を用いる。 右精度が 0 の場合は、基数点文字 (radix character) は印字されない (ここでの基数点文字は .B LC_MONETARY で定義されており、 .B LC_NUMERIC の指定とは異なっていてもよい)。 .LP .\"O Finally, the conversion specification must be ended with a .\"O conversion character. .\"O The three conversion characters are 最後に、変換指定は変換文字 (conversion character) で終了しなければならない。 変換文字には以下の 3 つがある。 .TP .B % .\"O (In this case the entire specification must be exactly "%%".) .\"O Put a \(aq%\(aq character in the result string. (この場合は指定全体が "%%" でなければならない。) 結果の文字列に \(aq%\(aq 文字を書きこむ。 .TP .B i .\"O One argument of type .\"O .I double .\"O is converted using the locale's international currency format. .I double 型の引き数ひとつが、 ロケールの国際通貨フォーマット (international currency format) を用いて変換される。 .TP .B n .\"O One argument of type .\"O .I double .\"O is converted using the locale's national currency format. .I double 型の引き数ひとつが、 ロケールの国内通貨フォーマット (national currency format) を用いて変換される。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O The .\"O .BR strfmon () .\"O function returns the number of characters placed .\"O in the array \fIs\fP, not including the terminating null byte, .\"O provided the string, including the terminating null byte, fits. .\"O Otherwise, it sets .\"O .I errno .\"O to .\"O .BR E2BIG , .\"O returns \-1, and the contents of the array is undefined. .BR strfmon () 関数は、結果の文字列が終端の NULL バイトを含めて配列 .I s に収まった場合には、 .I s に書きこまれた文字数を返す。NULL バイトは文字数に入らない。 それ以外の場合には、 .I errno に .B E2BIG を設定して \-1 を返す。 この場合の配列の内容は未定義である。 .\"O .SH "CONFORMING TO" .SH 準拠 .\"O Not in POSIX.1-2001. .\"O Present on several other systems. POSIX.1-2001 にはない。 他のいくつかのシステムに存在する。 .\"O .SH EXAMPLE .SH 例 .\"O The call .in +4n .nf strfmon(buf, sizeof(buf), "[%^=*#6n] [%=*#6i]", 1234.567, 1234.567); .fi .in のような関数コールの出力は、オランダのロケールでは以下のような出力になる。 .\"O outputs .in +4n [ fl **1234,57] [ NLG **1 234,57] .in .\"O in the Dutch locale (with fl for "florijnen" and NLG for Netherlands Guilders). (fl は "florijnen" の意。NLG は Netherlands Guilder。) .\"O The grouping character is very ugly because it takes as much space .\"O as a digit, while it should not take more than half that, .\"O and will no doubt cause confusion. .\"O Surprisingly, the "fl" is preceded and followed by a space, .\"O and "NLG" is preceded by one and followed by two spaces. .\"O This may be a bug in the locale files. .\"O The Italian, Australian, Swiss .\"O and Portuguese locales yield グループ化文字を用いると非常に醜くなる。 同時に間違いなく混乱の原因にもなってしまうだろう。 これは数値の半分以下の幅であるべきだが、 数値と同じだけの幅を取ってしまうからである。 ひどいことに、 "fl" の前後にはスペースが入ってしまい、 また "NLG" の前には 1 つ、後には 2 つのスペースが置かれている。 これはロケールファイルのバグであろう。 イタリア・オーストラリア・スイス・ポルトガルの 各ロケールでの結果は以下のようになる。 .in +4n [ L. **1235] [ ITL **1.235] .br [ $**1234.57] [ AUD **1,234.57] .br [Fr. **1234,57] [CHF **1.234,57] .br [ **1234$57Esc] [ **1.234$57PTE ] .in .\"O .SH "SEE ALSO" .SH 関連項目 .BR setlocale (3), .BR sprintf (3), .BR locale (7)