MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / unicode_cpts_from_utf8

Function unicode_cpts_from_utf8

smallthinker/src/unicode.cpp:616–631  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

614}
615
616std::vector<uint32_t> unicode_cpts_from_utf8(const std::string & utf8) {
617 std::vector<uint32_t> result;
618 result.reserve(utf8.size());
619 size_t offset = 0;
620 while (offset < utf8.size()) {
621 try {
622 result.push_back(unicode_cpt_from_utf8(utf8, offset));
623 }
624 catch (const std::invalid_argument & /*ex*/) {
625 // Silently ignore invalid UTF-8 input to avoid leaking the exception beyond llama_tokenize
626 ++offset;
627 result.emplace_back(0xFFFD); // replacement character
628 }
629 }
630 return result;
631}
632
633unicode_cpt_flags unicode_cpt_flags_from_cpt(const uint32_t cpt) {
634 static const unicode_cpt_flags undef(unicode_cpt_flags::UNDEFINED);

Callers 10

preprocessMethod · 0.85
llama_decode_textFunction · 0.85
unicode_regex_splitFunction · 0.85
match_stringFunction · 0.85
llama_grammar_validateFunction · 0.85
mainFunction · 0.85
match_stringFunction · 0.85

Calls 4

unicode_cpt_from_utf8Function · 0.85
reserveMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45

Tested by 4

match_stringFunction · 0.68
llama_grammar_validateFunction · 0.68
mainFunction · 0.68
match_stringFunction · 0.68