.\" Copyright (c) 2000 Andries Brouwer (aeb@cwi.nl) .\" .\" %%%LICENSE_START(GPLv2+_DOC_FULL) .\" 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, see .\" . .\" %%%LICENSE_END .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 2001 NAKANO Takeo all rights reserved. .\" Translated Thu Fri 08 2001 by NAKANO Takeo .\" .TH STRFMON 3 2020\-11\-01 Linux "Linux Programmer's Manual" .SH 名前 strfmon, strfmon_l \- convert monetary value to a string .SH 書式 .nf \fB#include \fP .PP \fBssize_t strfmon(char *\fP\fIs\fP\fB, size_t \fP\fImax\fP\fB, const char *\fP\fIformat\fP\fB, ...);\fP .PP \fBssize_t strfmon_l(char *\fP\fIs\fP\fB, size_t \fP\fImax\fP\fB, locale_t \fP\fIlocale\fP\fB,\fP \fB const char *\fP\fIformat\fP\fB, ...);\fP .fi .SH 説明 The \fBstrfmon\fP() function formats the specified monetary amount according to the current locale and format specification \fIformat\fP and places the result in the character array \fIs\fP of size \fImax\fP. .PP The \fBstrfmon_l\fP() function performs the same task, but uses the locale specified by \fIlocale\fP. The behavior of \fBstrfmon_l\fP() is undefined if \fIlocale\fP is the special locale object \fBLC_GLOBAL_LOCALE\fP (see \fBduplocale\fP(3)) or is not a valid locale object handle. .PP \fIformat\fP 中の通常の文字は、変換されずにそのまま \fIs\fP にコピーされる。変換指定は \(aq%\(aq 文字で始まる。 この直後には、以下のフラグを 0 個以上続けることができる。 .TP \fB=\fP\fIf\fP 1 バイト文字 \fIf\fP を数値埋め文字 (numeric fill character) にする (左精度と共に用いる。以下を参照)。 指定されないと、スペース文字が用いられる。 .TP \fB\(ha\fP 現在のロケールで定義されているであろうグループ化文字 (grouping character) を一切使わない。デフォルトではグループ化は有効になっている。 .TP \fB(\fP または \fB+\fP ( フラグは、負の数値を括弧で括ることを意味する。 + フラグは符号をデフォルトのように取り扱うことを意味する (すなわち数値の前にロケールの符号マークが置かれる。 例えば正ならなにもなく、負なら \(aq\-\(aq を置く、など)。 .TP \fB!\fP 通貨シンボルを省略する。 .TP \fB\-\fP すべてのフィールドを左詰めにする。デフォルトは右詰め。 .PP 次の位置には、フィールドの幅を指定できる。 10 進の数値文字列で、フィールドの最小幅をバイト単位で指定する。 デフォルトは 0。 結果がこの幅よりも狭くなった場合には、 不足分がスペースで埋められる (左詰めフラグが指定されていなければ左側が埋められる)。 .PP 次の位置には、"#" に 10 進数値文字列を続けた形式で、 左精度 (left precision) を指定できる。 通貨の基数点 (radix) より左側の数値の桁数がこの指定より小さい場合は、 数値埋め文字で左側が埋められる。 このフィールド幅の指定では、グループ化文字はカウントされない。 .PP 次の位置には、"." に 10 進数値文字列を続けた形式で、 右精度 (right precision) を指定できる。 整形される数値は、整形前にこの桁数に丸められる。 デフォルトではカレントロケールの \fIfrac_digits\fP と \fIint_frac_digits\fP の指定を用いる。 右精度が 0 の場合は、基数点文字 (radix character) は印字されない (ここでの基数点文字は \fBLC_MONETARY\fP で定義されており、 \fBLC_NUMERIC\fP の指定とは異なっていてもよい)。 .PP 最後に、変換指定は変換文字 (conversion character) で終了しなければならない。 変換文字には以下の 3 つがある。 .TP \fB%\fP (この場合は指定全体が "%%" でなければならない。) 結果の文字列に \(aq%\(aq 文字を書きこむ。 .TP \fBi\fP \fIdouble\fP 型の引数ひとつが、 ロケールの国際通貨フォーマット (international currency format) を用いて変換される。 .TP \fBn\fP \fIdouble\fP 型の引数ひとつが、 ロケールの国内通貨フォーマット (national currency format) を用いて変換される。 .SH 返り値 \fBstrfmon\fP() 関数は、結果の文字列が終端のヌルバイトを含めて配列 \fIs\fP に収まった場合には、 \fIs\fP に書きこまれた文字数を返す。ヌルバイトは文字数に入らない。 それ以外の場合には、 \fIerrno\fP に \fBE2BIG\fP を設定して \-1 を返す。 この場合の配列の内容は未定義である。 .SH 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .TS allbox; lb lb lb l l l. インターフェース 属性 値 T{ \fBstrfmon\fP() T} Thread safety MT\-Safe locale T{ \fBstrfmon_l\fP() T} Thread safety MT\-Safe .TE .sp 1 .SH 準拠 POSIX.1\-2001, POSIX.1\-2008. .SH 例 次のような関数コール .PP .in +4n .EX strfmon(buf, sizeof(buf), "[%\(ha=*#6n] [%=*#6i]", 1234.567, 1234.567); .EE .in .PP は、オランダのロケールでは以下のような出力になる。 .PP .in +4n .EX [€ **1234,57] [EUR **1 234,57] .EE .in .PP in the \fInl_NL\fP locale. The \fIde_DE\fP, \fIde_CH\fP, \fIen_AU\fP, and \fIen_GB\fP locales yield .PP .in +4n .EX [ **1234,57 €] [ **1.234,57 EUR] [ Fr. **1234.57] [ CHF **1\(aq234.57] [ $**1234.57] [ AUD**1,234.57] [ £**1234.57] [ GBP**1,234.57] .EE .in .SH 関連項目 \fBduplocale\fP(3), \fBsetlocale\fP(3), \fBsprintf\fP(3), \fBlocale\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。