chsvlib
chsv helper source code

◆ read_u8_char_data() [1/3]

constexpr u8_ch_data Chusov::String::read_u8_char_data ( const char(&)  pSymbol[N])
constexprnoexcept

Reads a UTF-8 character specified by an array of byte characters and constructs a u8_ch_data object with information about it.

Template Parameters
throw_on_failureA boolean flag which specifies whether the function should throw an exception when the multi-byte value in the array pSymbol specifies an invalid or incomplete UTF-8 character. If the flag is false, the function is marked noexcept and returns a default-constructed u8_ch_data object in case of an invalid/incomplete UTF-8 character. 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 read. Its size is not required be equal to the actual byte size of the UTF-8 code to obtain, but may be greater.
Returns
An object of type u8_ch_data. On success it describes a Unicode 11.0 code point of the multi-byte character having been read and its byte length. On failure, the function either throws an exception or returns a default-constructed u8_ch_data depending on the value of throw_on_failure.

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.
See also
Chusov::String::read_u8_char_data(InputIterator itSymbol, std::size_t cbSymbol = UTF8_MAX_LEN) "read_u8_char_data".