static SkUnichar NextUTF16()

in skiko/src/jvmMain/cpp/common/interop.cc [962:979]


static SkUnichar NextUTF16(const uint16_t** ptr, const uint16_t* end) {
    const uint16_t* src = *ptr;
    if (!src || src + 1 > end) {
        return -1;
    }
    uint16_t c = *src++;
    SkUnichar result = REPLACEMENT_CHARACTER;
    if (!utf16_is_surrogate(c)) { // It's single code point, use it as-is
        result = c;
    } else if (utf16_is_high_surrogate(c) && src < end) { // If it's valid start of surrogate range (high surrogate)
        uint16_t low = *src++;
        if (utf16_is_low_surrogate(low)) { // If it's valid end of surrogate range (low surrogate)
            result = (c << 10) + low - 0x35FDC00; // Combine high and low surrogates
        }
    }
    *ptr = src;
    return result;
}