whatwg_infra::surrogates

Function is_leading_surrogate_utf16

Source
pub const fn is_leading_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+DBFF, inclusive.

See also: WHATWG Infra Standard definition

ยงExamples

use whatwg_infra::surrogates::is_leading_surrogate_utf16;

assert_eq!(is_leading_surrogate_utf16(0xD799u16), false);
assert_eq!(is_leading_surrogate_utf16(0xD800u16), true);
assert_eq!(is_leading_surrogate_utf16(0xDBFFu16), true);
assert_eq!(is_leading_surrogate_utf16(0xDC00u16), false);