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

Function unicode_cpts_normalize_nfd

smallthinker/src/unicode.cpp:603–614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

601}
602
603std::vector<uint32_t> unicode_cpts_normalize_nfd(const std::vector<uint32_t> & cpts) {
604 auto comp = [] (const uint32_t cpt, const range_nfd & range) {
605 return cpt < range.first;
606 };
607 std::vector<uint32_t> result(cpts.size());
608 for (size_t i = 0; i < cpts.size(); ++i) {
609 const uint32_t cpt = cpts[i];
610 auto it = std::upper_bound(unicode_ranges_nfd.begin(), unicode_ranges_nfd.end(), cpt, comp) - 1;
611 result[i] = (it->first <= cpt && cpt <= it->last) ? it->nfd : cpt;
612 }
613 return result;
614}
615
616std::vector<uint32_t> unicode_cpts_from_utf8(const std::string & utf8) {
617 std::vector<uint32_t> result;

Callers 1

preprocessMethod · 0.85

Calls 3

sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected