wcsrtombs
Section: C Library Functions (3)
Updated: 2026-02-08
Index
JM Home Page
roff page
名前
wcsrtombs - ワイド文字文字列をマルチバイト文字列に変換する
ライブラリ
標準 C ライブラリ (libc,~-lc)
書式
#include <wchar.h>
size_t wcsrtombs(size_t dsize;
char dest[restrict dsize],
const wchar_t **restrict src,
size_t dsize, mbstate_t *restrict ps);
説明
If dest is not NULL, the wcsrtombs() function converts the
wide-character string *src to a multibyte string starting at dest. At
most dsize bytes are written to dest. The shift state *ps is
updated. The conversion is effectively performed by repeatedly calling
wcrtomb(dest, *src, ps), as long as this call succeeds, and then
incrementing dest by the number of bytes written and *src by one. The
conversion can stop for three reasons:
- •
-
(現在のロケールに基づいて)マルチバイト列で表現できないワイド文字に 出会った場合。この場合は、*src は不正なワイド文字を指した状態になり、
(size_t) -1 が返され、errno に EILSEQ が設定される。
- •
-
The size limit forces a stop. In this case, *src is left pointing to the
next wide character to be converted, and the number of bytes written to
dest is returned.
- •
-
The wide-character string has been completely converted, including the
terminating null wide character (L'\0'), which has the side
effect of bringing back *ps to the initial state. In this case, *src
is set to NULL, and the number of bytes written to dest, excluding the
terminating null byte ('\0'), is returned.
If dest is NULL, dsize is ignored, and the conversion proceeds as
above, except that the converted bytes are not written out to memory, and
that no size limit exists.
上記のいずれの場合も、ps が NULL ならば、wcsrtombs() 関数
だけが知っている静的な匿名の状態がシフト状態の代わりに用いられる。
The programmer must ensure that there is room for at least dsize bytes at
dest.
返り値
wcsrtombs() は、変換して得られたマルチバイト列のバイト数を返す。 これには終端の null バイトは含まれない。
変換できないワイド文字に出会った場合には (size_t) -1 が返され、 errno に EILSEQ が設定される。
属性
この節で使用されている用語の説明については、 attributes(7) を参照。
| インターフェース | 属性 | 値
|
|
wcsrtombs()
| Thread safety |
MT-Unsafe race:wcsrtombs/!ps
|
標準規格
C11, POSIX.1-2008.
歴史
POSIX.1-2001, C99.
注意
wcsrtombs() の動作は現在のロケールの LC_CTYPE カテゴリーに依存する。
ps に NULL を渡した際の動作はマルチスレッドセーフでない。
関連項目
iconv(3), mbsinit(3), wcrtomb(3), wcsnrtombs(3), wcstombs(3)
Index
- 名前
-
- ライブラリ
-
- 書式
-
- 説明
-
- 返り値
-
- 属性
-
- 標準規格
-
- 歴史
-
- 注意
-
- 関連項目
-
This document was created by
man2html,
using the manual pages.