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

Function append

include/utf8cpp/checked.h:73–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71
72 template <typename octet_iterator>
73 octet_iterator append(uint32_t cp, octet_iterator result)
74 {
75 if (!utf8::internal::is_code_point_valid(cp))
76 throw invalid_code_point(cp);
77
78 if (cp < 0x80) // one octet
79 *(result++) = static_cast<uint8_t>(cp);
80 else if (cp < 0x800) { // two octets
81 *(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
82 *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
83 }
84 else if (cp < 0x10000) { // three octets
85 *(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0);
86 *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
87 *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
88 }
89 else { // four octets
90 *(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0);
91 *(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f) | 0x80);
92 *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
93 *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
94 }
95 return result;
96 }
97
98 template <typename octet_iterator, typename output_iterator>
99 output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out, uint32_t replacement)

Callers 3

replace_invalidFunction · 0.70
utf16to8Function · 0.70
utf32to8Function · 0.70

Calls 2

is_code_point_validFunction · 0.85
invalid_code_pointClass · 0.85

Tested by

no test coverage detected