chsvlib
chsv helper source code

◆ u8_to_ucp() [1/2]

constexpr ucp_t Chusov::String::u8_to_ucp ( const char(&)  pSymbol[N])
constexprnoexcept

Converts a UTF-8 code read from an array of bytes to a Unicode 11.0 code point.

Template Parameters
do_full_checksspecifies whether the function should perform all checks for validity of the input UTF-8 code as specified by the section 3.9 of the Unicode 11.0 standard. If the flag is false, the function only performs basic checks necessary for the operation and the validity of the returned code point is not guaranteed.
throw_on_failureA boolean flag which specifies whether the function should throw an exception, if the multi-byte value in pSymbol specifies an invalid or incomplete UTF-8 character. If the flag is false, the function is marked noexcept and in case of failure returns INVALID_UNICODE_CODE_POINT. The default value is true.
Nis a deducible size of the array pSymbol.
Parameters
pSymbolis an array of char elements to contain the UTF-8 code to convert to ucp_t. Its size is not required be equal to the actual byte size of the UTF-8 code to obtain, but may be greater.
Returns
On success the function returns a Unicode 11.0 code point corresponding to the multi-byte UTF-8 character in pSymbol. On failure of conversion, when throw_on_failure is set to false, the function returns INVALID_UNICODE_CODE_POINT.

The function is constexpr when compiled by a C++14 compiler.

Exceptions
Chusov::Exceptions::InvalidCharSequenceExceptionThe multi-byte character given by the parameters is not a valid or complete UTF-8 code. The exception is only thrown when throw_on_failure is true.
Note
Success of a call to the function only guarantees a validity of the UTF-8 character when do_full_checks is true.
See also
u8_to_ucp Performs the conversion of a UTF-8 character given by an input iterator.
read_u8_char_data Obtains the code point, the byte size of the UTF-8 character and performs all of the validity checks at once.