chsvlib
chsv helper source code

◆ u8_decode_string() [6/8]

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

Produces a C++ string of Unicode 11.0 code points from bytes of a C++ container with a UTF-8 encoded string. .

Template Parameters
CharTraitsTospecifies a CharTraits type used to instantiate the std::basic_string class in order to produce the output string. By default it is an instantiation of std::char_traits for the type ucp_t. Such specialization is provided by the chsvlib library to treat ucp_t based strings as case-sensitive and 0-terminated.
AllocatorTois a type of an Allocator used to instantiate the returned string object. By default it resolves to
std::allocator<ucp_t>
.
Containeris a deducible type of a C++ Container, e.g. [std::vector], of the char based string to convert. See the note below about a use of the u8_decode_string function templates with C++ strings - std::basic_string and std::basic_string_view.
Parameters
stris a C++ Container of characters of the type char to hold the input UTF-8 string.
Returns
A newly created string, an instantiation of std::basic_string, with Unicode 11.0 code points as its elements along with optionally specified CharTraits and Allocator.
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. Another template implements this instead.
Exceptions
Chusov::Exceptions::InvalidCharSequenceExceptionThe specified UTF-8 string is detected to contain an invalid or incomplete multi-byte UTF-8 character.
See also
u8_decode_string An overload chosen if the parameter 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.