Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
utf8::unchecked Namespace Reference

Classes

class  iterator
 

Functions

template<typename octet_iterator >
octet_iterator append (uint32_t cp, octet_iterator result)
 
template<typename octet_iterator >
uint32_t next (octet_iterator &it)
 
template<typename octet_iterator >
uint32_t peek_next (octet_iterator it)
 
template<typename octet_iterator >
uint32_t prior (octet_iterator &it)
 
template<typename octet_iterator >
uint32_t previous (octet_iterator &it)
 
template<typename octet_iterator , typename distance_type >
void advance (octet_iterator &it, distance_type n)
 
template<typename octet_iterator >
std::iterator_traits< octet_iterator >::difference_type distance (octet_iterator first, octet_iterator last)
 
template<typename u16bit_iterator , typename octet_iterator >
octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
 
template<typename u16bit_iterator , typename octet_iterator >
u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
 
template<typename octet_iterator , typename u32bit_iterator >
octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result)
 
template<typename octet_iterator , typename u32bit_iterator >
u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result)
 

Function Documentation

◆ advance()

template<typename octet_iterator , typename distance_type >
void utf8::unchecked::advance ( octet_iterator & it,
distance_type n )

Definition at line 113 of file unchecked.h.

114 {
115 for (distance_type i = 0; i < n; ++i)
117 }
uint32_t next(octet_iterator &it)
Definition unchecked.h:61
Here is the call graph for this function:

◆ append()

template<typename octet_iterator >
octet_iterator utf8::unchecked::append ( uint32_t cp,
octet_iterator result )

Definition at line 38 of file unchecked.h.

39 {
40 if (cp < 0x80) // one octet
41 *(result++) = static_cast<uint8_t>(cp);
42 else if (cp < 0x800) { // two octets
43 *(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
44 *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
45 }
46 else if (cp < 0x10000) { // three octets
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);
50 }
51 else { // four octets
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);
56 }
57 return result;
58 }
unsigned char uint8_t
Definition stdint.h:124
Here is the caller graph for this function:

◆ distance()

template<typename octet_iterator >
std::iterator_traits< octet_iterator >::difference_type utf8::unchecked::distance ( octet_iterator first,
octet_iterator last )

Definition at line 121 of file unchecked.h.

122 {
123 typename std::iterator_traits<octet_iterator>::difference_type dist;
124 for (dist = 0; first < last; ++dist)
126 return dist;
127 }
Here is the call graph for this function:

◆ next()

template<typename octet_iterator >
uint32_t utf8::unchecked::next ( octet_iterator & it)

Definition at line 61 of file unchecked.h.

62 {
64 typename std::iterator_traits<octet_iterator>::difference_type length = utf8::internal::sequence_length(it);
65 switch (length) {
66 case 1:
67 break;
68 case 2:
69 it++;
70 cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
71 break;
72 case 3:
73 ++it;
74 cp = ((cp << 12) & 0xffff) + ((utf8::internal::mask8(*it) << 6) & 0xfff);
75 ++it;
76 cp += (*it) & 0x3f;
77 break;
78 case 4:
79 ++it;
80 cp = ((cp << 18) & 0x1fffff) + ((utf8::internal::mask8(*it) << 12) & 0x3ffff);
81 ++it;
82 cp += (utf8::internal::mask8(*it) << 6) & 0xfff;
83 ++it;
84 cp += (*it) & 0x3f;
85 break;
86 }
87 ++it;
88 return cp;
89 }
std::iterator_traits< octet_iterator >::difference_type sequence_length(octet_iterator lead_it)
Definition core.h:100
uint8_t mask8(octet_type oc)
Definition core.h:59
unsigned int uint32_t
Definition stdint.h:126
Here is the call graph for this function:
Here is the caller graph for this function:

◆ peek_next()

template<typename octet_iterator >
uint32_t utf8::unchecked::peek_next ( octet_iterator it)

Definition at line 92 of file unchecked.h.

93 {
94 return utf8::unchecked::next(it);
95 }
Here is the call graph for this function:

◆ previous()

template<typename octet_iterator >
uint32_t utf8::unchecked::previous ( octet_iterator & it)
inline

Definition at line 107 of file unchecked.h.

108 {
109 return utf8::unchecked::prior(it);
110 }
uint32_t prior(octet_iterator &it)
Definition unchecked.h:98
Here is the call graph for this function:

◆ prior()

template<typename octet_iterator >
uint32_t utf8::unchecked::prior ( octet_iterator & it)

Definition at line 98 of file unchecked.h.

99 {
100 while (utf8::internal::is_trail(*(--it))) ;
101 octet_iterator temp = it;
102 return utf8::unchecked::next(temp);
103 }
bool is_trail(octet_type oc)
Definition core.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ utf16to8()

template<typename u16bit_iterator , typename octet_iterator >
octet_iterator utf8::unchecked::utf16to8 ( u16bit_iterator start,
u16bit_iterator end,
octet_iterator result )

Definition at line 130 of file unchecked.h.

131 {
132 while (start != end) {
133 uint32_t cp = utf8::internal::mask16(*start++);
134 // Take care of surrogate pairs first
136 uint32_t trail_surrogate = utf8::internal::mask16(*start++);
137 cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
138 }
139 result = utf8::unchecked::append(cp, result);
140 }
141 return result;
142 }
bool is_lead_surrogate(u16 cp)
Definition core.h:75
uint16_t mask16(u16_type oc)
Definition core.h:64
octet_iterator append(uint32_t cp, octet_iterator result)
Definition unchecked.h:38
Here is the call graph for this function:

◆ utf32to8()

template<typename octet_iterator , typename u32bit_iterator >
octet_iterator utf8::unchecked::utf32to8 ( u32bit_iterator start,
u32bit_iterator end,
octet_iterator result )

Definition at line 160 of file unchecked.h.

161 {
162 while (start != end)
163 result = utf8::unchecked::append(*(start++), result);
164
165 return result;
166 }
Here is the call graph for this function:

◆ utf8to16()

template<typename u16bit_iterator , typename octet_iterator >
u16bit_iterator utf8::unchecked::utf8to16 ( octet_iterator start,
octet_iterator end,
u16bit_iterator result )

Definition at line 145 of file unchecked.h.

146 {
147 while (start < end) {
149 if (cp > 0xffff) { //make a surrogate pair
150 *result++ = static_cast<uint16_t>((cp >> 10) + internal::LEAD_OFFSET);
151 *result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN);
152 }
153 else
154 *result++ = static_cast<uint16_t>(cp);
155 }
156 return result;
157 }
unsigned short uint16_t
Definition stdint.h:125
Here is the call graph for this function:

◆ utf8to32()

template<typename octet_iterator , typename u32bit_iterator >
u32bit_iterator utf8::unchecked::utf8to32 ( octet_iterator start,
octet_iterator end,
u32bit_iterator result )

Definition at line 169 of file unchecked.h.

170 {
171 while (start < end)
172 (*result++) = utf8::unchecked::next(start);
173
174 return result;
175 }
Here is the call graph for this function: