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

Function UTF8StartCodepoint

src/string.cpp:487–498  ·  view source on GitHub ↗

Finds the byte index of the front of a codepoint by reversing until a non-continuation byte is found. */

Source from the content-addressed store, hash-verified

485
486/** Finds the byte index of the front of a codepoint by reversing until a non-continuation byte is found. */
487static size_t UTF8StartCodepoint(const std::string& s8, size_t pos) {
488 // Check out of bounds
489 if (pos >= s8.size())
490 return s8.size();
491 while (pos > 0) {
492 // Check for continuation byte 0b10xxxxxx
493 if ((s8[pos] & 0xc0) != 0x80)
494 break;
495 pos--;
496 }
497 return pos;
498}
499
500
501size_t UTF8PrevCodepoint(const std::string& s8, size_t pos) {

Callers 1

UTF8PrevCodepointFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected