| 511 | |
| 512 | |
| 513 | size_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 | |
| 529 | size_t UTF8CodepointPos(const std::string& s8, size_t endIndex) { |
no test coverage detected