MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / utf8_sequence_len

Function utf8_sequence_len

internal/cbm/extract_defs.c:6870–6881  ·  view source on GitHub ↗

Bytes the sequence starting with `lead` occupies (1 for ASCII or a byte that * is not a valid lead). */

Source from the content-addressed store, hash-verified

6868/* Bytes the sequence starting with `lead` occupies (1 for ASCII or a byte that
6869 * is not a valid lead). */
6870static size_t utf8_sequence_len(unsigned char lead) {
6871 if ((lead & UTF8_LEAD2_MASK) == UTF8_LEAD2_MARK) {
6872 return UTF8_LEN_2;
6873 }
6874 if ((lead & UTF8_LEAD3_MASK) == UTF8_LEAD3_MARK) {
6875 return UTF8_LEN_3;
6876 }
6877 if ((lead & UTF8_LEAD4_MASK) == UTF8_LEAD4_MARK) {
6878 return UTF8_LEN_4;
6879 }
6880 return UTF8_LEN_1;
6881}
6882
6883/* Drop a trailing PARTIAL UTF-8 sequence left behind by a byte-length cut, so
6884 * a capped prose value never ends mid-codepoint (#1017's rule, applied to the

Callers 1

utf8_trim_partial_tailFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected