wcstombs
Section: C Library Functions (3)
Updated: 2026-02-08
Index
JM Home Page
roff page
名前
wcstombs - ワイド文字列をマルチバイト文字列に変換する
ライブラリ
標準 C ライブラリ (libc,~-lc)
書式
#include <stdlib.h>
size_t wcstombs(size_t dsize;
char dest[restrict dsize], const wchar_t *restrict src,
size_t dsize);
説明
If dest is not NULL, the wcstombs() function converts the
wide-character string src to a multibyte string starting at dest. At
most dsize bytes are written to dest. The sequence of characters
placed in dest begins in the initial shift state. The conversion can
stop for three reasons:
- •
-
(現在のロケールにおける)マルチバイト列で表現できないワイド文字に 遭遇した場合。この場合には (size_t) -1 が返される。
- •
-
長さ制限によって強制停止させられた場合。この場合には dest に 書き込まれたバイト数が返される。しかしこの時点でのシフト状態は失われる。
- •
-
The wide-character string has been completely converted, including the
terminating null wide character (L'\0'). In this case, the
conversion ends in the initial shift state. The number of bytes written to
dest, excluding the terminating null byte ('\0'), is
returned.
The programmer must ensure that there is room for at least dsize bytes at
dest.
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 no
length limit exists.
In order to avoid the case 2 above, the programmer should make sure dsize
is greater than or equal to wcstombs(NULL,src,0)+1.
返り値
wcstombs() 関数は生成したマルチバイト列のバイト数を返す。終端の ヌル文字は含まない。もし変換できないワイド文字に遭遇した場合には
(size_t) -1 を返す。
属性
この節で使用されている用語の説明については、 attributes(7) を参照。
| インターフェース | 属性 | 値
|
|
wcstombs()
| Thread safety | MT-Safe
|
バージョン
wcsrtombs(3) 関数は同じ機能のより良いインターフェースを提供する。
標準規格
C11, POSIX.1-2008.
歴史
POSIX.1-2001, C99.
注意
wcstombs() の動作は現在のロケールの LC_CTYPE カテゴリーに依存している。
関連項目
mblen(3), mbstowcs(3), mbtowc(3), wcsrtombs(3), wctomb(3)
Index
- 名前
-
- ライブラリ
-
- 書式
-
- 説明
-
- 返り値
-
- 属性
-
- バージョン
-
- 標準規格
-
- 歴史
-
- 注意
-
- 関連項目
-
This document was created by
man2html,
using the manual pages.