mbsrtowcs
Section: C Library Functions (3)
Updated: 2026-02-08
Index
JM Home Page
roff page
名前
mbsrtowcs - convert a multibyte string to a wide-character string
(restartable)
ライブラリ
標準 C ライブラリ (libc,~-lc)
書式
#include <wchar.h>
size_t mbsrtowcs(size_t dsize;
wchar_t dest[restrict dsize],
const char **restrict src,
size_t dsize, mbstate_t *restrict ps);
説明
If dest is not NULL, convert the multibyte string *src to a
wide-character string starting at dest. At most dsize wide characters
are written to dest. The shift state *ps is updated. The conversion
is effectively performed by repeatedly calling mbrtowc(dest, *src, n, ps)
where n is some positive number, as long as this call succeeds, and then
incrementing dest by one and *src by the number of bytes consumed.
The conversion can stop for three reasons:
- •
-
不正なマルチバイト列に遭遇した。この場合には *src は不正な マルチバイト列を指すようにして、 (size_t) -1
を返し、errno に EILSEQ を設定する。
- •
-
dsize non-L'\0' wide characters have been stored at dest.
In this case, *src is left pointing to the next multibyte sequence to be
converted, and the number of wide characters written to dest is returned.
- •
-
The multibyte string has been completely converted, including the
terminating null wide character ('\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 wide characters written to dest,
excluding the terminating null wide character, is returned.
If dest is NULL, dsize is ignored, and the conversion proceeds as
above, except that the converted wide characters are not written out to
memory, and that no length limit exists.
上記のどちらの場合でも、ps が NULL ならば、 代りに mbsrtowcs() 関数のみが使用する静的で名前のない状態が使用される。
In order to avoid the case 2 above, the programmer should make sure dsize
is greater than or equal to mbsrtowcs(NULL,src,0,ps)+1.
The programmer must ensure that there is room for at least dsize wide
characters at dest.
This function is a restartable version of mbstowcs(3).
返り値
The number of wide characters that make up the converted part of the
wide-character string, not including the terminating null wide character.
If an invalid multibyte sequence was encountered, (size_t) -1 is
returned, and errno set to EILSEQ.
属性
この節で使用されている用語の説明については、 attributes(7) を参照。
| インターフェース | 属性 | 値
|
|
mbsrtowcs()
| Thread safety |
MT-Unsafe race:mbsrtowcs/!ps
|
標準規格
C11, POSIX.1-2008.
歴史
POSIX.1-2001, C99.
注意
mbsrtowcs() の動作は現在のロケールの LC_CTYPE カテゴリーに依存している。
ps に NULL を渡した際の動作はマルチスレッドセーフでない。
関連項目
iconv(3), mbrtowc(3), mbsinit(3), mbsnrtowcs(3), mbstowcs(3)
Index
- 名前
-
- ライブラリ
-
- 書式
-
- 説明
-
- 返り値
-
- 属性
-
- 標準規格
-
- 歴史
-
- 注意
-
- 関連項目
-
This document was created by
man2html,
using the manual pages.