MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / utf8AppendCodepoint

Function utf8AppendCodepoint

lib/Utf8/Utf8.cpp:127–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127void utf8AppendCodepoint(uint32_t cp, std::string& out) {
128 if (cp < 0x80) {
129 out += static_cast<char>(cp);
130 } else if (cp < 0x800) {
131 out += static_cast<char>(0xC0 | (cp >> 6));
132 out += static_cast<char>(0x80 | (cp & 0x3F));
133 } else if (cp < 0x10000) {
134 out += static_cast<char>(0xE0 | (cp >> 12));
135 out += static_cast<char>(0x80 | ((cp >> 6) & 0x3F));
136 out += static_cast<char>(0x80 | (cp & 0x3F));
137 } else {
138 out += static_cast<char>(0xF0 | (cp >> 18));
139 out += static_cast<char>(0x80 | ((cp >> 12) & 0x3F));
140 out += static_cast<char>(0x80 | ((cp >> 6) & 0x3F));
141 out += static_cast<char>(0x80 | (cp & 0x3F));
142 }
143}
144
145int utf8SafeTruncateBuffer(const char* buf, int len) {
146 if (len <= 0) return 0;

Callers 2

utf8ComposeNfcFunction · 0.85
applyBidiVisualFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected