chsvlib
chsv helper source code

◆ u8_encode_string() [6/8]

std::basic_string<char, CharTraits, Allocator> Chusov::String::u8_encode_string ( const ucp_t(&)  pUcp[N])

Converts a given array with a string of Unicode code points to the corresponding UTF-8 representation and returns the latter as a C++ string object. .

Template Parameters
CharTraitsis a CharTraits object used to instantiate the std::basic_string template and create the output string. By default it resolves to
std::char_traits<char>
.
Allocatoris an Allocator object to instantiate the std::basic_string to produce the type of the resulting string. By default it resolves to
std::allocator<char>
.
Nis a deducible size of pUcp. This size will not necessarily be equal to the length of the resulting string, unless pUcp is not zero-terminated.
Parameters
pUcpis a statically defined array of Unicode 11.0 code points to convert to the corresponding UTF-8 representation. If the last byte of the array has zero value, it is truncated from the resulting string of Unicode code points.
Returns
A newly created multi-byte char based C++ string object holding the UTF-8 representation of pUcp.
Exceptions
Chusov::Exceptions::InvalidCharSequenceExceptionThe input string is detected to contain invalid code points.