MCPcopy Create free account
hub / github.com/axmolengine/axmol / countUTF8Chars

Function countUTF8Chars

core/base/UTF8.cpp:408–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

406}
407
408size_t countUTF8Chars(std::string_view utf8)
409{
410 int count = 0;
411
412 if (!utf8.empty())
413 {
414 const UTF8* source = (const UTF8*)utf8.data();
415 const UTF8* sourceEnd = (const UTF8*)utf8.data() + utf8.length();
416 while (source != sourceEnd)
417 {
418 auto size = getUTF8SequenceSize(source, sourceEnd);
419 if (size == 0)
420 {
421 // Invalid UTF-8 sequence found
422 return 0;
423 }
424 source += size;
425 ++count;
426 }
427 }
428
429 return count;
430}
431
432size_t getUTF8ByteOffset(std::string_view utf8, size_t utf8CharOffset)
433{

Callers 10

insertTextMethod · 0.85
replaceMethod · 0.85
setStringMethod · 0.85
insertTextMethod · 0.85
setPasswordTextMethod · 0.85
setStringMethod · 0.85
UTF8Tests.cppFile · 0.85
initMethod · 0.85

Calls 4

getUTF8SequenceSizeFunction · 0.85
emptyMethod · 0.45
dataMethod · 0.45
lengthMethod · 0.45

Tested by 1

initMethod · 0.68