Creates a Unicode code point from UTF16 surrogate pair.
| 3289 | |
| 3290 | // Creates a Unicode code point from UTF16 surrogate pair. |
| 3291 | inline UInt32 CreateCodePointFromUtf16SurrogatePair(wchar_t first, |
| 3292 | wchar_t second) { |
| 3293 | const auto first_u = static_cast<UInt32>(first); |
| 3294 | const auto second_u = static_cast<UInt32>(second); |
| 3295 | const UInt32 mask = (1 << 10) - 1; |
| 3296 | return (sizeof(wchar_t) == 2) |
| 3297 | ? (((first_u & mask) << 10) | (second_u & mask)) + 0x10000 |
| 3298 | : |
| 3299 | // This function should not be called when the condition is |
| 3300 | // false, but we provide a sensible default in case it is. |
| 3301 | first_u; |
| 3302 | } |
| 3303 | |
| 3304 | // Converts a wide string to a narrow string in UTF-8 encoding. |
| 3305 | // The wide string is assumed to have the following encoding: |