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

Function codepoint_from_utf16

unicode.h:326–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324}
325
326static uint32_t codepoint_from_utf16(const std::vector<uint16_t> & utf16, size_t & offset) {
327 assert(offset < utf16.size());
328 if (((utf16[0] >> 10) << 10) != 0xd800) {
329 auto result = utf16[offset + 0];
330 offset += 1;
331 return result;
332 }
333 else {
334 if (offset + 1 >= utf16.size() || !((utf16[1] & 0xdc00) == 0xdc00))
335 throw std::invalid_argument("invalid character");
336 auto result = 0x10000 + (((utf16[0] & 0x03ff) << 10) | (utf16[1] & 0x03ff));
337 offset += 2;
338 return result;
339 }
340 throw std::invalid_argument("invalid string");
341}
342
343static std::vector<uint32_t> codepoints_from_utf16(const std::vector<uint16_t> & utf16) {
344 std::vector<uint32_t> result;

Callers 1

codepoints_from_utf16Function · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected