MCPcopy Create free account
hub / github.com/VCVRack/Rack / UTF8CodepointSize

Function UTF8CodepointSize

src/string.cpp:457–470  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

455
456
457static size_t UTF8CodepointSize(char c) {
458 if (!c) return 0;
459 // First byte signals size
460 // 0b0xxxxxxx
461 if ((c & 0x80) == 0x00) return 1;
462 // 0b110xxxxx
463 if ((c & 0xe0) == 0xc0) return 2;
464 // 0b1110xxxx
465 if ((c & 0xf0) == 0xe0) return 3;
466 // 0b11110xxx
467 if ((c & 0xf8) == 0xf0) return 4;
468 // Invalid first UTF-8 byte
469 return 0;
470}
471
472
473size_t UTF8NextCodepoint(const std::string& s8, size_t pos) {

Callers 1

UTF8NextCodepointFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected