|
noexcept |
Determines the number of bytes needed to represent a Unicode 11.0 code point as a multibyte UTF-8 code and optionally performs the conversion and stores the resulting UTF-8 code in the specified buffer.
[out] | pUtf | is an optional pointer to a buffer to store the multibyte equivalent of the code point. At most UTF8_LEN_MAX bytes are stored. If pUtf is NULL , the function returns 0 indicating a state-independence of the UTF-8 encoding. |
[in] | ucp | is the Unicode code point to encode in the UTF-8 format. If pUtf is not NULL , it receives the UTF-8 representation of ucp . |
pUtf
pointer is NULL
, the function returns 0 indicating a state-independence of the UTF-8 (to correspond to the [wcstomb] requirements given by the C standard). If pUtf
is not a NULL
pointer, the function returns -1 setting errno
to EILSEQ
, if the code point cannot be converted to a UTF-8 code due to its invalid value, or an actual number of bytes of the UTF-8 representation of ucp
.A successful call of the function does not guarantee validity of the UTF-8 representation. To verify the code point one should use the u8check_cp function.
The function is built in a portable way to perform the conversion to UTF-8 representation independently of the current locale.
The interface is built similarly to the wctomb function specified by the C standard except for the maximum possible byte length of the UTF-8 characters which is UTF8_MAX_LEN
and not MB_CUR_MAX
or MB_LEN_MAX
.