|
noexcept |
Verifies validity of a given UTF-8 code according to the Unicode 11.0 standard.
pUtf8 | is a buffer with a UTF-8 code to check. |
cbUtf8 | is a number of bytes of the pUtf8 code to check. It must be exactly equal to the byte size of the code to check, not greater or less. The size can be obtained beforehand from a call to the u8len function. |
true
, if the specified code is a valid UTF-8 byte sequence, or false
otherwise.The function verifies the byte size of the code to exactly correspond the value of the code and the value to be in the set of valid UTF-8 code values as specified by the Unicode 11.0 format.
To check the code one usually has to obtain an actual byte size of the code in a larger buffer. To do this one can call the u8len function prior to a call to u8check
. Note that in case of an invalid code value u8len can also fail with EILSEQ
errno
code without returning the required size.
Also, if the caller performs a conversion to a Unicode code point, it would be more efficient to conduct the conversion using the u8toucp function, which accepts buffers larger than the byte size of a converted character, verify if it fails with the EILSEQ
code and, if not, perform additional check of the validity of the code point itself using the u8check_cp function.