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

Function UTF8CodepointIndex

src/string.cpp:513–526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

511
512
513size_t UTF8CodepointIndex(const std::string& s8, size_t endPos) {
514 size_t pos = 0;
515 size_t index = 0;
516 endPos = std::min(endPos, s8.size());
517 while (pos < endPos) {
518 size_t newPos = UTF8NextCodepoint(s8, pos);
519 // Check if codepoint is invalid
520 if (pos == newPos)
521 return index;
522 pos = newPos;
523 index++;
524 }
525 return index;
526}
527
528
529size_t UTF8CodepointPos(const std::string& s8, size_t endIndex) {

Callers 2

UTF8LengthFunction · 0.85
drawMethod · 0.85

Calls 3

minFunction · 0.85
UTF8NextCodepointFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected