MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / common_unicode_cpt_to_utf8

Function common_unicode_cpt_to_utf8

common/unicode.cpp:94–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94std::string common_unicode_cpt_to_utf8(uint32_t cpt) {
95 std::string result;
96
97 if (/* 0x00 <= cpt && */ cpt <= 0x7f) {
98 result.push_back(cpt);
99 return result;
100 }
101 if (0x80 <= cpt && cpt <= 0x7ff) {
102 result.push_back(0xc0 | ((cpt >> 6) & 0x1f));
103 result.push_back(0x80 | (cpt & 0x3f));
104 return result;
105 }
106 if (0x800 <= cpt && cpt <= 0xffff) {
107 result.push_back(0xe0 | ((cpt >> 12) & 0x0f));
108 result.push_back(0x80 | ((cpt >> 6) & 0x3f));
109 result.push_back(0x80 | (cpt & 0x3f));
110 return result;
111 }
112 if (0x10000 <= cpt && cpt <= 0x10ffff) {
113 result.push_back(0xf0 | ((cpt >> 18) & 0x07));
114 result.push_back(0x80 | ((cpt >> 12) & 0x3f));
115 result.push_back(0x80 | ((cpt >> 6) & 0x3f));
116 result.push_back(0x80 | (cpt & 0x3f));
117 return result;
118 }
119
120 throw std::invalid_argument("invalid codepoint");
121}
122
123
124

Callers 1

Calls 1

push_backMethod · 0.45

Tested by

no test coverage detected