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

Function unicode_len_utf8

smallthinker/src/unicode.cpp:22–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20#include <vector>
21
22size_t unicode_len_utf8(char src) {
23 const size_t lookup[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 4 };
24 uint8_t highbits = static_cast<uint8_t>(src) >> 4;
25 return lookup[highbits];
26}
27
28static std::string unicode_cpts_to_utf8(const std::vector<uint32_t> & cps) {
29 std::string result;

Callers 3

tokenizeMethod · 0.85
tokenizeMethod · 0.85
tokenizeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected