MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / sz_utf8_count_serial

Function sz_utf8_count_serial

include/stringzilla/utf8.h:414–426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412}
413
414SZ_PUBLIC sz_size_t sz_utf8_count_serial(sz_cptr_t text, sz_size_t length) {
415 sz_u8_t const *text_u8 = (sz_u8_t const *)text;
416 sz_u8_t const *end_u8 = text_u8 + length;
417 sz_size_t char_count = 0;
418
419 while (text_u8 < end_u8) {
420 // Count this byte if it's NOT a continuation byte
421 if ((*text_u8 & 0xC0) != 0x80) char_count++;
422 text_u8++;
423 }
424
425 return char_count;
426}
427
428SZ_PUBLIC sz_cptr_t sz_utf8_find_nth_serial(sz_cptr_t text, sz_size_t length, sz_size_t n) {
429 sz_u8_t const *text_u8 = (sz_u8_t const *)text;

Callers 3

sz_utf8_count_haswellFunction · 0.85
sz_utf8_count_neonFunction · 0.85
sz_utf8_countFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…