chsvlib
chsv helper source code

◆ u8_encode_string() [7/8]

std::basic_string<char, CharTraits, Allocator> Chusov::String::u8_encode_string ( CPtr &&  pszUcp)

Converts a given zero-terminated string of Unicode code points to its 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>
.
CPtris a (referenced) type of a possibly cv-qualified pointer to a C-string of ucp_t characters. This overload of u8_encode_string does not participate in overload resolution unless CPtr is a (possibly referenced and/or cv_qualified) pointer to ucp_t.
Parameters
pszUcpis a pointer to a zero terminated string of ucp_t code points to convert to an output UTF-8 C++ representation.
Returns
A newly created multi-byte char based C++ string object holding the UTF-8 representation of pszUcp.
Exceptions
Chusov::Exceptions::InvalidCharSequenceExceptionThe input string is detected to contain invalid code points.
Note
The CPtr template parameter is introduced to disambiguate calls to this overload as opposed to the overload which accepts references to arrays of ucp_t.
See also
ucp_t