wcsnrtombs

Section: C Library Functions (3)
Updated: 2026-02-08
Index JM Home Page roff page
 

名前

wcsnrtombs - ワイド文字文字列をマルチバイト文字列に変換する  

ライブラリ

標準 C ライブラリ (libc,~-lc)  

書式

#include <wchar.h>

size_t wcsnrtombs(size_t dsize;
                  char dest[restrict dsize],
                  const wchar_t **restrict src,
                  size_t nwc, size_t dsize, mbstate_t *restrict ps);

glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):

wcsnrtombs():

    Since glibc 2.10:
        _POSIX_C_SOURCE >= 200809L
    Before glibc 2.10:
        _GNU_SOURCE
 

説明

wcsnrtombs() 関数は、 wcsrtombs() 関数に似ている。ただし、 変換されるワイド文字の数が(*src から数えて) nwc 文字に制限 されている点が異なる。

If dest is not NULL, the wcsnrtombs() function converts at most nwc wide characters from 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 が設定される。
•
nwc wide characters have been converted without encountering a null wide character (L'\0'), or 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 (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 destination size limit exists.

上記のいずれの場合も、ps が NULL ならば、wcsnrtombs() 関数 だけが知っている静的な匿名の状態がシフト状態の代わりに用いられる。

The programmer must ensure that there is room for at least dsize bytes at dest.  

返り値

wcsrtombs() は、変換して得られたマルチバイト列のバイト数を返す。 これには終端の null バイトは含まれない。 変換できないワイド文字に出会った場合には (size_t) -1 が返され、 errno に EILSEQ が設定される。  

属性

この節で使用されている用語の説明については、 attributes(7) を参照。
インターフェース属性値
wcsnrtombs() Thread safety MT-Unsafe race:wcsnrtombs/!ps
 

標準規格

POSIX.1-2008.  

注意

wcsnrtombs() の動作は現在のロケールの LC_CTYPE カテゴリーに依存する。

ps に NULL を渡した際の動作はマルチスレッドセーフでない。  

関連項目

iconv(3), mbsinit(3), wcsrtombs(3)


 

Index

名前
ライブラリ
書式
説明
返り値
属性
標準規格
注意
関連項目

This document was created by man2html, using the manual pages.