CppCMS
|
Geneneric generic codecvt facet, various stateless encodings to UTF-16 and UTF-32 using wchar_t, char32_t and char16_t. More...
#include <booster/booster/locale/generic_codecvt.h>
Geneneric generic codecvt facet, various stateless encodings to UTF-16 and UTF-32 using wchar_t, char32_t and char16_t.
Implementations should dervide from this class defining itself as CodecvtImpl and provide following members
state_type
- a type of special object that allows to store intermediate cached data, for example iconv_t
descriptorstate_type initial_state(generic_codecvt_base::initial_convertion_state direction) const
- member function that creates initial stateint max_encoding_length() const
- a maximal length that one Unicode code point is represented, for UTF-8 for example it is 4 from ISO-8859-1 it is 1utf::code_point to_unicode(state_type &state,char const *&begin,char const *end)
- extract first code point from the text in range [begin,end), in case of success begin would point to the next character sequence to be encoded to next code point, in case of incomplete sequence - utf::incomplete shell be returned, and in case of invalid input sequence utf::illegal shell be returned and begin would remain unmodifiedutf::code_point from_unicode(state_type &state,utf::code_point u,char *begin,char const *end)
- convert a unicode code point u
into a character seqnece at [begin,end). Return the length of the sequence in case of success, utf::incomplete in case of not enough room to encode the code point of utf::illegal in case conversion can not be performedFor example implementaion of codecvt for latin1/ISO-8859-1 character set
When external tools used for encoding conversion, the state_type
is useful to save objects used for conversions. For example, icu::UConverter can be saved in such a state for an efficient use: