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

Function codepoint_to_utf16

unicode.h:302–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300}
301
302static std::vector<uint16_t> codepoint_to_utf16(uint32_t cp) {
303 std::vector<uint16_t> result;
304 if (/* 0x0000 <= cp && */ cp <= 0xffff) {
305 result.emplace_back(cp);
306 }
307 else if (0x10000 <= cp && cp <= 0x10ffff) {
308 result.emplace_back(0xd800 | ((cp - 0x10000) >> 10));
309 result.emplace_back(0xdc00 | ((cp - 0x10000) & 0x03ff));
310 }
311 else {
312 throw std::invalid_argument("invalid codepoint");
313 }
314 return result;
315}
316
317static std::vector<uint16_t> codepoints_to_utf16(const std::vector<uint32_t> & cps) {
318 std::vector<uint16_t> result;

Callers 1

codepoints_to_utf16Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected