c/string/multibyte/c8rtomb

Converts a single code point from UTF-8 to a narrow multibyte character representation.

If is not a null pointer and  is the last code unit in a valid UTF-8 encoding of a code point, the function determines the number of bytes necessary to store the multibyte character representation of that code point (including any shift sequences, and taking into account the current multibyte conversion state ), and stores the multibyte character representation in the character array whose first element is pointed to by, updating  as necessary. At most mb_cur_max bytes can be written by this function.

If is not the final UTF-8 code unit in a representation of a code point, the function does not write to the array pointed to by, only  is updated.

If is a null pointer, the call is equivalent to  for some internal buffer.

If is the null character, a null byte is stored, preceded by any shift sequence necessary to restore the initial shift state and the conversion state parameter  is updated to represent the initial shift state.

The multibyte encoding used by this function is specified by the currently active C locale.

Return value
The number of bytes stored in the array object (including any shift sequences). This may be zero when is not the final code unit in the UTF-8 representation of a code point.

If is invalid (does not contribute to a sequence of  corresponding to a valid multibyte character), the value of the macro eilseq is stored in errno,  is returned, and the conversion state is unspecified.