| Updated: October 28, 2024 |
Convert a wide character (UTF-16 or UTF-32) into a multibyte character (UTF-8)
#include <uchar.h>
size_t c16rtomb( char *s,
char16_t wc,
mbstate_t *pst );
size_t c32rtomb( char *s,
char32_t wc,
mbstate_t *pst );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
If s isn't NULL, the c16rtomb() and c32rtomb() functions convert the wide character wc (UTF-16 for type char16_t or UTF-32 for type char32_t) into a multibyte character (UTF-8). The multibyte character is stored in the location referenced by s, to a maximum of MB_CUR_MAX bytes.
c16rtomb(buf, L'\0', pst)or
c32rtomb(buf, L'\0', pst)where buf is an internal buffer. The mbstate_t object referenced by pst is then reset to its initial conversion state.
The number of bytes needed to convert the wide character, or -1 if wc isn't a valid wide character.
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | No |
| Signal handler | Yes |
| Thread | Yes |