28 #ifndef UTF8_FOR_CPP_UNCHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
29 #define UTF8_FOR_CPP_UNCHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
37 template <
typename octet_iterator>
41 *(result++) = static_cast<uint8_t>(cp);
42 else if (cp < 0x800) {
43 *(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
44 *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
46 else if (cp < 0x10000) {
47 *(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0);
48 *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
49 *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
52 *(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0);
53 *(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f)| 0x80);
54 *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
55 *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
60 template <
typename octet_iterator>
70 cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
91 template <
typename octet_iterator>
97 template <
typename octet_iterator>
101 octet_iterator temp = it;
106 template <
typename octet_iterator>
112 template <
typename octet_iterator,
typename distance_type>
113 void advance (octet_iterator& it, distance_type n)
115 for (distance_type i = 0; i < n; ++i)
119 template <
typename octet_iterator>
120 typename std::iterator_traits<octet_iterator>::difference_type
121 distance (octet_iterator first, octet_iterator last)
123 typename std::iterator_traits<octet_iterator>::difference_type dist;
124 for (dist = 0; first < last; ++dist)
129 template <
typename u16bit_iterator,
typename octet_iterator>
130 octet_iterator
utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
132 while (start != end) {
144 template <
typename u16bit_iterator,
typename octet_iterator>
145 u16bit_iterator
utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
147 while (start < end) {
154 *result++ =
static_cast<uint16_t>(cp);
159 template <
typename octet_iterator,
typename u32bit_iterator>
160 octet_iterator
utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result)
168 template <
typename octet_iterator,
typename u32bit_iterator>
169 u32bit_iterator
utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result)
178 template <
typename octet_iterator>
179 class iterator :
public std::iterator <std::bidirectional_iterator_tag, uint32_t> {
183 explicit iterator (
const octet_iterator& octet_it): it(octet_it) {}
185 octet_iterator
base ()
const {
return it; }
188 octet_iterator temp =
it;
193 return (it == rhs.
it);
227 #endif // header guard
Definition: unchecked.h:179
octet_iterator append(uint32_t cp, octet_iterator result)
Definition: unchecked.h:38
std::iterator_traits< octet_iterator >::difference_type sequence_length(octet_iterator lead_it)
Definition: core.h:100
octet_iterator it
Definition: unchecked.h:180
const uint16_t TRAIL_SURROGATE_MIN
Definition: core.h:50
u32bit_iterator utf8to32(octet_iterator start, octet_iterator end, u32bit_iterator result)
Definition: unchecked.h:169
bool operator!=(const iterator &rhs) const
Definition: unchecked.h:195
uint32_t peek_next(octet_iterator it)
Definition: unchecked.h:92
iterator & operator++()
Definition: unchecked.h:199
std::iterator_traits< octet_iterator >::difference_type distance(octet_iterator first, octet_iterator last)
Definition: unchecked.h:121
iterator()
Definition: unchecked.h:182
uint32_t next(octet_iterator &it)
Definition: unchecked.h:61
octet_iterator utf32to8(u32bit_iterator start, u32bit_iterator end, octet_iterator result)
Definition: unchecked.h:160
bool is_lead_surrogate(u16 cp)
Definition: core.h:75
u16bit_iterator utf8to16(octet_iterator start, octet_iterator end, u16bit_iterator result)
Definition: unchecked.h:145
iterator & operator--()
Definition: unchecked.h:210
uint32_t previous(octet_iterator &it)
Definition: unchecked.h:107
uint8_t mask8(octet_type oc)
Definition: core.h:59
octet_iterator base() const
Definition: unchecked.h:185
iterator(const octet_iterator &octet_it)
Definition: unchecked.h:183
const uint32_t SURROGATE_OFFSET
Definition: core.h:53
bool operator==(const iterator &rhs) const
Definition: unchecked.h:191
octet_iterator utf16to8(u16bit_iterator start, u16bit_iterator end, octet_iterator result)
Definition: unchecked.h:130
uint16_t mask16(u16_type oc)
Definition: core.h:64
unsigned short uint16_t
Definition: core.h:39
float length(float v)
Definition: vectorMath.h:208
void advance(octet_iterator &it, distance_type n)
Definition: unchecked.h:113
unsigned int uint32_t
Definition: core.h:40
bool is_trail(octet_type oc)
Definition: core.h:69
const uint16_t LEAD_OFFSET
Definition: core.h:52
uint32_t prior(octet_iterator &it)
Definition: unchecked.h:98
uint32_t operator*() const
Definition: unchecked.h:186