MCPcopy Create free account
hub / github.com/JuliaStrings/utf8proc / charbound_encode_char

Function charbound_encode_char

utf8proc.c:204–230  ·  view source on GitHub ↗

internal version used for inserting 0xff bytes between graphemes */

Source from the content-addressed store, hash-verified

202
203/* internal version used for inserting 0xff bytes between graphemes */
204static utf8proc_ssize_t charbound_encode_char(utf8proc_int32_t uc, utf8proc_uint8_t *dst) {
205 if (uc < 0x00) {
206 if (uc == -1) { /* internal value used for grapheme breaks */
207 dst[0] = (utf8proc_uint8_t)0xFF;
208 return 1;
209 }
210 return 0;
211 } else if (uc < 0x80) {
212 dst[0] = (utf8proc_uint8_t)uc;
213 return 1;
214 } else if (uc < 0x800) {
215 dst[0] = (utf8proc_uint8_t)(0xC0 + (uc >> 6));
216 dst[1] = (utf8proc_uint8_t)(0x80 + (uc & 0x3F));
217 return 2;
218 } else if (uc < 0x10000) {
219 dst[0] = (utf8proc_uint8_t)(0xE0 + (uc >> 12));
220 dst[1] = (utf8proc_uint8_t)(0x80 + ((uc >> 6) & 0x3F));
221 dst[2] = (utf8proc_uint8_t)(0x80 + (uc & 0x3F));
222 return 3;
223 } else if (uc < 0x110000) {
224 dst[0] = (utf8proc_uint8_t)(0xF0 + (uc >> 18));
225 dst[1] = (utf8proc_uint8_t)(0x80 + ((uc >> 12) & 0x3F));
226 dst[2] = (utf8proc_uint8_t)(0x80 + ((uc >> 6) & 0x3F));
227 dst[3] = (utf8proc_uint8_t)(0x80 + (uc & 0x3F));
228 return 4;
229 } else return 0;
230}
231
232/* internal "unsafe" version that does not check whether uc is in range */
233static const utf8proc_property_t *unsafe_get_property(utf8proc_int32_t uc) {

Callers 1

utf8proc_reencodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected