| 324 | } |
| 325 | |
| 326 | static 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 | |
| 343 | static std::vector<uint32_t> codepoints_from_utf16(const std::vector<uint16_t> & utf16) { |
| 344 | std::vector<uint32_t> result; |
no test coverage detected