Converts the wide character to its multibyte character representation.
#include <wchar.h> size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps);
wcrtomb (buf, L'\0', ps)
where buf is an internal buffer.
If s is not a NULL pointer, the wcrtomb function determines the number of bytes needed to represent the multibyte character that corresponds to the wide character specified by wc (including any shift sequences), and stores the resulting bytes in the array whose first element is pointed to by s. At most MB_CUR_MAX bytes are stored.
If wc 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.
n | The number of bytes stored in the resulting array, including any shift sequences to represent the multibyte character. |
-1 | Indicates an encoding error. The wc argument is not a valid wide character. The global errno is set to EILSEQ; the conversion state is undefined. |