c32rtomb - restartable multibyte/wide character conversion function
#include <uchar.h> size_t c32rtomb(char * restrict s, char32_t c32, mbstate_t * restrict ps);
If s is a null pointer, the c32rtomb() function is equivalent to the call
c32rtomb(buf, L'\0', ps)
where buf is an internal buffer.
If s is not a null pointer, the c32rtomb() function determines the number of bytes needed to represent the multibyte character that corresponds to the wide character given by c32 (including any shift sequences), and stores the multibyte character representation in the array whose first element is pointed to by s. At most MB_CUR_MAX bytes are stored. If c32 is a null wide character, a null byte is stored, preceded by any shift sequence needed to restore the initial shift state; the resulting state described is the initial conversion state.
The c32rtomb() function returns the number of bytes stored in the array object (including any shift sequences). When c32 is not a valid wide character, an encoding error occurs: the function stores the value of the macro EILSEQ in errno and returns (size_t)(-1); the conversion state is unspecified.
The c32rtomb() function will fail if:
The ps argument points to an object that contains an invalid conversion state.
Invalid character sequence is detected.
The c32rtomb() function may fail if:
Insufficient storage space is available.
See attributes(7) for descriptions of the following attributes:
|
mbsinit(3C), setlocale(3C), attributes(7), standards(7)
If ps is not a null pointer, the function uses the mbstate_t object pointed to by ps and the function can be used safely in multithreaded applications. If ps is a null pointer, the function uses its internal mbstate_t object and the function is Unsafe in multithreaded applications.