vfwprintfのヘルプ・マニュアル
日本語 英語
vfwprintf --help
man vfwprintf
WPRINTF(3) Linux Programmer’s Manual WPRINTF(3)
名前
wprintf, fwprintf, swprintf, vwprintf, vfwprintf, vswprintf - ワイド文
字をフォーマットして出力する
書式
#include
#include
int wprintf(const wchar_t *format, ...);
int fwprintf(FILE *stream, const wchar_t *format, ...);
int swprintf(wchar_t *wcs, size_t maxlen,
const wchar_t *format, ...);
int vwprintf(const wchar_t *format, va_list args);
int vfwprintf(FILE *stream, const wchar_t *format, va_list args);
int vswprintf(wchar_t *wcs, size_t maxlen,
const wchar_t *format, va_list args);
glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):
上記の全ての関数: _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE; or
cc -std=c99
説明
wprintf() ファミリーの関数は printf(3) ファミリーの関数のワイド文字版で
ある。これらはワイド文字をフォーマットして出力する。
wprintf() と vwprintf() 関数は stdout に出力を行なう。 stdout がバイ ト
単 位入出力であってはいけない。より詳しい説明は fwide(3) を参照すること
。
fwprintf() と vfwprintf() 関数は stream にワイド文字出力 を 行 な う 。
stream がバイト単位入出力であってはいけない。より詳しい説明は fwide(3)
を参照すること。
swprintf() と vswprintf() 関数はワイド文字の配列にワイド文字出力を行 な
う。プログラマーは wcs に最低でも maxlen 文字のワイド文字を出力できる空
きがあることを保証しなければならない。
これ ら の 関 数 は printf(3), vprintf(3), fprintf(3), vfprintf(3),
sprintf(3), vsprintf(3) 関数に似ているが以下の点で異っている。
· format がワイド文字列で与えられる。
· 出力がバイトではなくワイド文字で構成される。
· swprintf() と vswprintf() は maxlen 引き数を取るが、 sprintf()
と vsprintf() は取らない (snprintf() と vsnprintf() は maxlen 引
き 数を取るがこれらの関数が Linux では、バッファーが溢れた場合で
も -1 を返さない)。
c と s 変換文字の扱いが異っている:
c もし l 修飾子が存在しない場合は int 引き数は btowc(3) 関数によっ
てワイド文字に変換される。そして結果のワイド文字が出力される。 l
修飾子が存在する場合は wint_t (ワイド文字)引き数が出力される。
s もし l 修飾子が存在しない場合、 const char * 引き数は初期状態 よ
り 始まるマルチバイト文字列を含んだ char 型の配列へのポインター(
文字列へのポインター)とみなされる。配列の文字は(最初のバイト前に
初 期 状態で変換を開始し、それぞれの文字を mbrtowc(3) 関数によっ
て)ワイド文字へと変換される。結果のワイド文字は終端のナルワイ ド
文 字の手前までが書き込まれる。精度(precision)が指定された場合、
指定された数字を超えるワイド文字は書き込まれない。精度は書き込ま
れ る バイト数や 画面上の位置ではなく ワイド文字の数を指定するこ
とに注意すること。精度がない場合には配列の終端にナル文字を含む必
要がある。精度を指定する場合には、配列の最後に到着する前に変換さ
れたワイド文字の数がそれに到達するよう、精度は十分に小さな数でな
ければならない。もし l 修飾子が存在する場合、 const wchar_t * 引
き数はワイド文字の配列へのポインターとみなされる。配列のワイド文
字列は終端のナルワイド文字の手間まで出力される。もし精度が指定さ
れた場合には指定された精度以上の文字は出力されない。精度を指定し
ない場合には終端のナルワイド文字を含む必要がある。精度を指定する
場合にはそれはワイド文字の配列の大きさよりも小さくなければならな
い。
返り値
これらの関数は書き込まれたワイド文字の文字数を返す。 swprintf() と vsw-
printf() 関数の場合は終端のナルワイド文字は含まない。エラーが起こった場
合は -1 を返す。
準拠
C99.
注意
wprintf() 等の動作は現在のロケールの LC_CTYPE カテゴリに依存している。
format 文字列が ASCII 以外のワイド文字を含んでいる場合、実行時のロケー
ルの LC_CTYPE カテゴリがコンパイル時の LC_CTYPE カテゴリと一致してい る
場合にのみプログラムは正常に動作する。これは wchar_t の表現がロケールや
プラットホームに依存していることに原因がある。 (glibc ではワイド文字 と
して Unicode (ISO-10646) のコードポイントを使用している。他のプラットホ
ームではそうではない。同様に ISO C99 の \unnnn 形式の汎用文字名称はこの
問 題を解決しない。) このため国際化されたプログラムでは format 文字列を
ASCII ワイド文字のみにするか、実行時に国際化された方法で構成する必要 が
ある (例えば gettext() と iconv() や mbstowcs() を組み合わて使用する)。
関連項目
fprintf(3), fputwc(3), fwide(3), printf(3), snprintf(3)
GNU 2007-07-26 WPRINTF(3)
WPRINTF(3) Linux Programmer’s Manual WPRINTF(3)
NAME
wprintf, fwprintf, swprintf, vwprintf, vfwprintf, vswprintf - formatted
wide-character output conversion
SYNOPSIS
#include
#include
int wprintf(const wchar_t *format, ...);
int fwprintf(FILE *stream, const wchar_t *format, ...);
int swprintf(wchar_t *wcs, size_t maxlen,
const wchar_t *format, ...);
int vwprintf(const wchar_t *format, va_list args);
int vfwprintf(FILE *stream, const wchar_t *format, va_list args);
int vswprintf(wchar_t *wcs, size_t maxlen,
const wchar_t *format, va_list args);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
All functions shown above: _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE; or
cc -std=c99
DESCRIPTION
The wprintf() family of functions is the wide-character equivalent of
the printf(3) family of functions. It performs formatted output of
wide characters.
The wprintf() and vwprintf() functions perform wide-character output to
stdout. stdout must not be byte oriented; see fwide(3) for more infor-
mation.
The fwprintf() and vfwprintf() functions perform wide-character output
to stream. stream must not be byte oriented; see fwide(3) for more
information.
The swprintf() and vswprintf() functions perform wide-character output
to an array of wide characters. The programmer must ensure that there
is room for at least maxlen wide characters at wcs.
These functions are like the printf(3), vprintf(3), fprintf(3),
vfprintf(3), sprintf(3), vsprintf(3) functions except for the following
differences:
· The format string is a wide-character string.
· The output consists of wide characters, not bytes.
· swprintf() and vswprintf() take a maxlen argument, sprintf(3)
and vsprintf(3) do not. (snprintf(3) and vsnprintf(3) take a
maxlen argument, but these functions do not return -1 upon
buffer overflow on Linux.)
The treatment of the conversion characters c and s is different:
c If no l modifier is present, the int argument is converted to a
wide character by a call to the btowc(3) function, and the
resulting wide character is written. If an l modifier is
present, the wint_t (wide character) argument is written.
s If no l modifier is present: The const char * argument is
expected to be a pointer to an array of character type (pointer
to a string) containing a multibyte character sequence beginning
in the initial shift state. Characters from the array are con-
verted to wide characters (each by a call to the mbrtowc(3)
function with a conversion state starting in the initial state
before the first byte). The resulting wide characters are writ-
ten up to (but not including) the terminating null wide charac-
ter. If a precision is specified, no more wide characters than
the number specified are written. Note that the precision
determines the number of wide characters written, not the number
of bytes or screen positions. The array must contain a termi-
nating null byte, unless a precision is given and it is so small
that the number of converted wide characters reaches it before
the end of the array is reached. If an l modifier is present:
The const wchar_t * argument is expected to be a pointer to an
array of wide characters. Wide characters from the array are
written up to (but not including) a terminating null wide char-
acter. If a precision is specified, no more than the number
specified are written. The array must contain a terminating
null wide character, unless a precision is given and it is
smaller than or equal to the number of wide characters in the
array.
RETURN VALUE
The functions return the number of wide characters written, excluding
the terminating null wide character in case of the functions swprintf()
and vswprintf(). They return -1 when an error occurs.
CONFORMING TO
C99.
NOTES
The behavior of wprintf() et al. depends on the LC_CTYPE category of
the current locale.
If the format string contains non-ASCII wide characters, the program
will only work correctly if the LC_CTYPE category of the current locale
at run time is the same as the LC_CTYPE category of the current locale
at compile time. This is because the wchar_t representation is plat-
form- and locale-dependent. (The glibc represents wide characters
using their Unicode (ISO-10646) code point, but other platforms don’t
do this. Also, the use of C99 universal character names of the form
\unnnn does not solve this problem.) Therefore, in internationalized
programs, the format string should consist of ASCII wide characters
only, or should be constructed at run time in an internationalized way
(e.g., using gettext(3) or iconv(3), followed by mbstowcs(3)).
SEE ALSO
fprintf(3), fputwc(3), fwide(3), printf(3), snprintf(3)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
GNU 2007-07-26 WPRINTF(3)