chsvlib
chsv helper source code

◆ u8_encode_string() [5/8]

std::basic_string<char, CharTraitsTo, AllocatorTo> Chusov::String::u8_encode_string ( const Container &  str)

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

Template Parameters
CharTraitsTois 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>
.
AllocatorTois 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>
.
Containeris a deducible type of a C++ Container of the ucp_t based string of Unicode code points to convert to the UTF-8 representation.
Parameters
stris an input C++ Container of characters of the type ucp_t specifying the input string of Unicode code points.
Returns
A newly created multi-byte char based C++ string object holding the UTF-8 representation of str.
Note
This overload does not participate in the overload resolution if Container is an std::basic_string or (C++17) [std::basic_string_view] object with the traits_type subtype be a template of one type argument.
Exceptions
Chusov::Exceptions::InvalidCharSequenceExceptionThe input string is detected to contain invalid code points.
See also
u8_encode_string An overload chosen if the str is an std::basic_string or (C++17) [std::basic_string_view] object with the traits_type subtype be a template of one type argument.