chsvlib
chsv helper source code

◆ ucp_to_u8()

constexpr OutputIterator Chusov::String::ucp_to_u8 ( OutputIterator  it,
ucp_t  ucp 
)
constexprnoexcept

Converts a given Unicode 11.0 code point to a sequence of bytes representing the corresponding UTF-8 multi-byte character and writes the bytes to a given output iterator.

Template Parameters
do_full_checksspecifies whether the function should perform all checks for validity of the input Unicode code point 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 produced UTF-8 code is not guaranteed.
throw_on_failureA boolean flag which specifies whether the function should throw an exception when the Unicode code point is not valid as described below. If the flag is false, the function is marked noexcept and in case of failure the function does not write anything or changes the state of the output iterator.
OutputIteratoris a deducible parameter which is a type of it.
Parameters
itis an output iterator into which the writing of the produced UTF-8 bytes should take place.
ucpis a Unicode 11.0 code point to convert to a sequence of bytes representing the respective UTF-8 code.
Returns
A copy of it shifted according to the number of bytes produced and written to it.

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

Exceptions
Chusov::Exceptions::InvalidCharSequenceExceptionThe specified Unicode code point is not valid according to Unicode 11.0. The exception is only thrown when throw_on_failure is true.

A code is considered valid if it belongs to the range \(\left[0, \textrm{0xd7ff}\right]\cup\left[\textrm{0xe000}, \textrm{0x10ffff}\right]\).

See also
u8_array_from_ucp A compile time alternative which creates an array of bytes representing a given Unicode 11.0 code point in the UTF-8 format.