whatwg_infra::surrogates

Function is_surrogate_utf16

Source
pub const fn is_surrogate_utf16(c: u16) -> bool
Expand description

Checks if a u16 is a UTF-16 codepoint defined in the range of U+D800 to U+DFFF, inclusive.

See also: WHATWG Infra Standard definition

Note: This function substitutes the nightly-gated feature in Rust, utf16_extra (issue #94919).

ยงExamples

use whatwg_infra::surrogates::is_surrogate_utf16;

assert_eq!(is_surrogate_utf16(0xD799u16), false);
assert_eq!(is_surrogate_utf16(0xD809u16), true);
assert_eq!(is_surrogate_utf16(0xDB99u16), true);
assert_eq!(is_surrogate_utf16(0xDFFFu16), true);
assert_eq!(is_surrogate_utf16(0xE000u16), false);