wcrtombのヘルプ・マニュアル
日本語 英語
wcrtomb --help
man wcrtomb
WCRTOMB(3) Linux Programmer’s Manual WCRTOMB(3)
名前
wcrtomb - ワイド文字 1 つをマルチバイト列に変換する
書式
#include
size_t wcrtomb(char *s, wchar_t wc, mbstate_t *ps);
説明
こ の関数が主に使われるのは、s が NULL でなく、wc が L'\0' でない場合で
ある。この場合には、 wcrtomb() 関数はワイド文字 wc をマルチバイト表現に
変 換 し 、s が指す char 型の配列にこれを格納する。この関数はシフト状態
*ps を更新し、出力されたマルチバイト表現の長さ、すなわち s に書き込まれ
たバイト数を返す。
別のケースとしては、s は NULL でないが wc が L'\0' のことがある。この場
合の wcrtomb() 関数は、*ps を初期状態に戻すのに必要なシフトシーケンスを
s が指す char 型配列に格納し、その後に '\0' を格納する。この関数はシフ
ト状態 *ps を更新し(つまり初期状態に戻し)、シフトシーケンスの長さ に 1
を加えた値を返す。この値は s に書き込まれたバイト数である。
三 番目のケースは、s が NULL の時である。この場合には wc は無視され、関
数の実際の効果としては wcrtomb(buf,L'\0',ps) と同じ値が返される。ここで
、buf は内部的な匿名のバッファである。
以上のいずれの場合も、ps が NULL ポインタならばシフト状態は用いられず、
wcrtomb() 関数だけが知っている静的な匿名の状態が使われる。
返り値
wcrtomb() 関数は、s が指すバイト列に書き込まれたバイト数、あるいは書 き
込まれたであろうバイト数を返す。wc を(現在のロケールに従って)マルチバイ
ト列で表現できなければ、 (size_t) -1 が返され、 errno に EILSEQ が設 定
される。
準拠
C99.
注意
wcrtomb() の動作は、現在のロケールの LC_CTYPE カテゴリに依存する。
ps に NULL を渡した際の動作はマルチスレッドセーフでない。
関連項目
wcsrtombs(3)
GNU 1999-07-25 WCRTOMB(3)
WCRTOMB(3) Linux Programmer’s Manual WCRTOMB(3)
NAME
wcrtomb - convert a wide character to a multibyte sequence
SYNOPSIS
#include
size_t wcrtomb(char *s, wchar_t wc, mbstate_t *ps);
DESCRIPTION
The main case for this function is when s is not NULL and wc is not
L'\0'. In this case, the wcrtomb() function converts the wide charac-
ter wc to its multibyte representation and stores it at the beginning
of the character array pointed to by s. It updates the shift state
*ps, and returns the length of said multibyte representation, that is,
the number of bytes written at s.
A different case is when s is not NULL but wc is L'\0'. In this case
the wcrtomb() function stores at the character array pointed to by s
the shift sequence needed to bring *ps back to the initial state, fol-
lowed by a '\0' byte. It updates the shift state *ps (i.e., brings it
into the initial state), and returns the length of the shift sequence
plus one, that is, the number of bytes written at s.
A third case is when s is NULL. In this case wc is ignored, and the
function effectively returns wcrtomb(buf,L'\0',ps) where buf is an
internal anonymous buffer.
In all of the above cases, if ps is a NULL pointer, a static anonymous
state only known to the wcrtomb() function is used instead.
RETURN VALUE
The wcrtomb() function returns the number of bytes that have been or
would have been written to the byte array at s. If wc can not be rep-
resented as a multibyte sequence (according to the current locale),
(size_t) -1 is returned, and errno set to EILSEQ.
CONFORMING TO
C99.
NOTES
The behavior of wcrtomb() depends on the LC_CTYPE category of the cur-
rent locale.
Passing NULL as ps is not multithread safe.
SEE ALSO
wcsrtombs(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 1999-07-25 WCRTOMB(3)