p Each character will be converted as if .Xr wcrtomb 3 is continuously called, except the internal state of .Xr wcrtomb 3 will not be affected.
p After conversion, if .Fa s is not a NULL pointer, the pointer object pointed to by .Fa pwcs is a NULL pointer
q if the conversion is stopped due to reaching a NUL wide character or points to the first byte of the character just after the last character converted.
p If .Fa s is not a NULL pointer and the conversion is stopped due to reaching a NUL wide character, .Fn wcsrtombs places the state object pointed to by .Fa ps to an initial state after the conversion is taken place.
p The behavior of .Fn wcsrtombs is affected by the .Dv LC_CTYPE category of the current locale.
p These are the special cases: l -tag -width Li t Li "s == NULL" .Fn wcsrtombs returns the number of bytes to store the whole multibyte character string corresponding to the wide-character string pointed to by .Fa pwcs , not including the terminating NUL byte. In this case, .Fa n is ignored. t Li "pwcs == NULL || *pwcs == NULL" Undefined (may cause the program to crash). t Li "ps == NULL" .Fn wcsrtombs uses its own internal state object to keep the conversion state, instead of .Fa ps mentioned in this manual page.
p Calling any other functions in .Lb libc never changes the internal state of .Fn wcsrtombs , which is initialized at startup time of the program. .El
p
The
.Fn wcsnrtombs
function behaves identically to
.Fn wcsrtombs ,
except that the conversion stops after reading at most
.Fa nwc
characters from the buffer pointed to by
.Fa pwcs .
----------------------------------------------------------------------
.Sh RETURN VALUES
The
.Fn wcsrtombs
and
.Fn wcsnrtombs
functions return:
l -tag -width Li t Li 0 , No or positive Number of bytes stored in the array pointed to by
.Fa s ,
except for a NUL byte.
There are no cases that the value returned is greater than
.Fa n
o unless .Fa s is a NULL pointer
c .
If the return value is equal to
.Fa n ,
the string pointed to by
.Fa s
will not be NUL-terminated.
t Li "(size_t)-1" .Fa pwcs
points to a string containing an invalid wide character.
The
.Fn wcsrtombs
also sets
.Va errno
to indicate the error.
.El
----------------------------------------------------------------------
.Sh ERRORS
The
.Fn wcsrtombs
and
.Fn wcsnrtombs
functions may fail with the following errors:
l -tag -width Er t Bq Er EILSEQ .Fa pwcs
points to a string containing an invalid wide character.
t Bq Er EINVAL .Fa ps
points to an invalid or uninitialized
.Vt mbstate_t
object.
.El
----------------------------------------------------------------------
.Sh SEE ALSO
.Xr setlocale 3 ,
.Xr wcrtomb 3 ,
.Xr wcstombs 3
----------------------------------------------------------------------
.Sh STANDARDS
The
.Fn wcsrtombs
function conforms to
.St -ansiC .
The
.Li restrict
qualifier was added by
.St -isoC-99 .
p The .Fn wcsnrtombs function conforms to .St -p1003.1-2008 .