whatwg_infra::scalar

Function is_c0_control

Source
pub const fn is_c0_control(c: char) -> bool
Expand description

Checks if a character is a C0 control, as originally defined by the ANSI X3.4 standard, and redefined by the WHATWG Infra Standard.

Any character is a C0 control if it’s within the inclusive range of U+0000 NULL or U+001F INFORMATION SEPARATOR ONE.

This method is subtly different than char::is_ascii_control() and u8::is_ascii_control() which also checks for U+007F DELETE.

See also: WHATWG Infra Standard definition

§Examples

use whatwg_infra::scalar::is_c0_control;

assert!(is_c0_control('\u{0000}'));
assert!(is_c0_control('\u{001E}'));
assert!(is_c0_control('\u{001F}'));