MCPcopy Create free account
hub / github.com/apache/fory / utf16_to_utf8

Function utf16_to_utf8

cpp/fory/util/string_util.h:71–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71inline void utf16_to_utf8(uint16_t code_unit, char *&output) {
72 if (code_unit < 0x80) {
73 *output++ = static_cast<char>(code_unit);
74 } else if (code_unit < 0x800) {
75 *output++ = static_cast<char>(0xC0 | (code_unit >> 6));
76 *output++ = static_cast<char>(0x80 | (code_unit & 0x3F));
77 } else {
78 *output++ = static_cast<char>(0xE0 | (code_unit >> 12));
79 *output++ = static_cast<char>(0x80 | ((code_unit >> 6) & 0x3F));
80 *output++ = static_cast<char>(0x80 | (code_unit & 0x3F));
81 }
82}
83
84inline void utf16_surrogate_pair_to_utf8(uint16_t high, uint16_t low,
85 char *&utf8) {

Callers 3

TESTFunction · 0.70
write_u16string_dataFunction · 0.50
read_string_dataFunction · 0.50

Calls 3

stringFunction · 0.50
resizeMethod · 0.45

Tested by 1

TESTFunction · 0.56