c16rtomb - restartable multibyte/wide character conversion function
#include <uchar.h> size_t c16rtomb(char * restrict s, char16_t c16, mbstate_t * restrict ps);
If s is a null pointer, the c16rtomb() function is equivalent to the call
c16rtomb(buf, L'\0', ps)
where buf is an internal buffer.
If s is not a null pointer, the c16rtomb() function determines the number of bytes needed to represent the multibyte character that corresponds to the wide character given by c16 (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 c16 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 c16rtomb() function returns the number of bytes stored in the array object (including any shift sequences). When c16 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 c16rtomb() function will fail if:
The ps argument points to an object that contains an invalid conversion state.
Invalid character sequence is detected.
The c16rtomb() 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.