MCPcopy Create free account
hub / github.com/cinder/Cinder / utf16to8

Function utf16to8

include/utf8cpp/checked.h:207–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205
206 template <typename u16bit_iterator, typename octet_iterator>
207 octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
208 {
209 while (start != end) {
210 uint32_t cp = utf8::internal::mask16(*start++);
211 // Take care of surrogate pairs first
212 if (utf8::internal::is_lead_surrogate(cp)) {
213 if (start != end) {
214 uint32_t trail_surrogate = utf8::internal::mask16(*start++);
215 if (utf8::internal::is_trail_surrogate(trail_surrogate))
216 cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
217 else
218 throw invalid_utf16(static_cast<uint16_t>(trail_surrogate));
219 }
220 else
221 throw invalid_utf16(static_cast<uint16_t>(cp));
222
223 }
224 // Lone trail surrogate
225 else if (utf8::internal::is_trail_surrogate(cp))
226 throw invalid_utf16(static_cast<uint16_t>(cp));
227
228 result = utf8::append(cp, result);
229 }
230 return result;
231 }
232
233 template <typename u16bit_iterator, typename octet_iterator>
234 u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)

Callers 1

toUtf8Function · 0.50

Calls 5

mask16Function · 0.85
is_lead_surrogateFunction · 0.85
is_trail_surrogateFunction · 0.85
invalid_utf16Class · 0.85
appendFunction · 0.70

Tested by

no test coverage detected