c16rtomb
Defined in header
<uchar.h>
|
||
(since C11) | ||
Converts a 16-bit wide character to narrow multibyte character.
If s
is not a null pointer, the function determines the number of bytes necessary to store the multibyte character representation of c16
(including any shift sequences), and stores the multibyte character representation in the character array whose first element is pointed to by s
. At most MB_CUR_MAX bytes can be written by this function.
If s
is a null pointer, the call is equivalent to c16rtomb(buf, u'\0', ps) for some internal buffer buf
.
If c16 is the null wide character u'\0', a null byte is stored, preceded by any shift sequence necessary to restore the initial shift state and the conversion state parameter *ps is updated to represent the initial shift state.
If the macro __STDC_UTF_16__ is defined, the 16-bit encoding used by this function is UTF-16, otherwise it is implementation-defined. In any case, the multibyte encoding used by this function is specified by the currently active C locale.
[edit] Parameters
s | - | pointer to narrow character array where the multibyte character will be stored |
c16 | - | the 16-bit character to convert |
ps | - | pointer to the conversion state object used when interpreting the multibyte string |
[edit] Return value
On success, returns the number of bytes (including any shift sequences) written to the character array whose first element is pointed to by s
. This value may be 0, e.g. when processing the first char16_t in a surrogate pair.
On failure (if c16 is not a valid 16-bit character), returns -1, stores EILSEQ in errno, and leaves *ps in unspecified state.
[edit] See also
(C11)
|
generate the next 16-bit wide character from a narrow multibyte string (function) |
C++ documentation for c16rtomb
|