28 #ifndef UTF8_FOR_CPP_CORE_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
29 #define UTF8_FOR_CPP_CORE_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
58 template<
typename octet_type>
61 return static_cast<uint8_t>(0xff & oc);
63 template<
typename u16_type>
66 return static_cast<uint16_t>(0xffff & oc);
68 template<
typename octet_type>
71 return ((
mask8(oc) >> 6) == 0x2);
74 template <
typename u16>
80 template <
typename u32>
86 template <
typename octet_iterator>
87 inline typename std::iterator_traits<octet_iterator>::difference_type
93 else if ((lead >> 5) == 0x6)
95 else if ((lead >> 4) == 0xe)
97 else if ((lead >> 3) == 0x1e)
105 template <
typename octet_iterator>
110 typedef typename std::iterator_traits<octet_iterator>::difference_type octet_difference_type;
136 cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
145 cp = ((cp << 12) & 0xffff) + ((
mask8(*it) << 6) & 0xfff);
161 cp = ((cp << 18) & 0x1fffff) + ((
mask8(*it) << 12) & 0x3ffff);
163 cp += (
mask8(*it) << 6) & 0xfff;
185 for (octet_difference_type i = 0; i < length - 1; ++i)
199 else if (cp < 0x800) {
205 else if (cp < 0x10000) {
216 template <
typename octet_iterator>
228 template <
typename octet_iterator>
231 octet_iterator result = start;
232 while (result != end) {
240 template <
typename octet_iterator>
241 inline bool is_valid(octet_iterator start, octet_iterator end)
246 template <
typename octet_iterator>
257 #endif // header guard
const uint16_t LEAD_SURROGATE_MAX
const uint16_t TRAIL_SURROGATE_MAX
std::iterator_traits< octet_iterator >::difference_type sequence_length(octet_iterator lead_it)
const uint16_t TRAIL_SURROGATE_MIN
const uint32_t CODE_POINT_MAX
uint8_t mask8(octet_type oc)
void advance(octet_iterator &it, distance_type n, octet_iterator end)
bool is_code_point_valid(u32 cp)
const uint32_t SURROGATE_OFFSET
bool is_valid(octet_iterator start, octet_iterator end)
uint16_t mask16(u16_type oc)
octet_iterator find_invalid(octet_iterator start, octet_iterator end)
std::iterator_traits< octet_iterator >::difference_type distance(octet_iterator first, octet_iterator last)
const uint8_t bom[]
The library API - functions intended to be called by the users.
bool is_surrogate(u16 cp)
utf_error validate_next(octet_iterator &it, octet_iterator end, uint32_t *code_point)
bool is_bom(octet_iterator it)
bool is_trail(octet_type oc)
const uint16_t LEAD_OFFSET
const uint16_t LEAD_SURROGATE_MIN