| 69 | } |
| 70 | |
| 71 | inline 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 | |
| 84 | inline void utf16_surrogate_pair_to_utf8(uint16_t high, uint16_t low, |
| 85 | char *&utf8) { |