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

Function UTF8NextCodepoint

src/string.cpp:473–483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

471
472
473size_t UTF8NextCodepoint(const std::string& s8, size_t pos) {
474 // Check out of bounds
475 if (pos >= s8.size())
476 return s8.size();
477 size_t size = UTF8CodepointSize(s8[pos]);
478 // Check for continuation byte 0b10xxxxxx
479 // if ((s8[1] & 0xc0) != 0x80) return 0;
480 // if ((s8[2] & 0xc0) != 0x80) return 0;
481 // if ((s8[3] & 0xc0) != 0x80) return 0;
482 return std::min(pos + size, s8.size());
483}
484
485
486/** Finds the byte index of the front of a codepoint by reversing until a non-continuation byte is found. */

Callers 7

truncateFunction · 0.85
ellipsizePrefixFunction · 0.85
positionToLocationFunction · 0.85
locationToPositionFunction · 0.85
UTF8CodepointIndexFunction · 0.85
UTF8CodepointPosFunction · 0.85
onSelectKeyMethod · 0.85

Calls 3

UTF8CodepointSizeFunction · 0.85
minFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected