2019-12-23 06:48:41 -05:00
|
|
|
// Official spec defined code points.
|
|
|
|
// See https://infra.spec.whatwg.org/#code-points for spec.
|
|
|
|
|
|
|
|
pub fn is_whitespace(c: u8) -> bool {
|
2020-01-01 22:14:40 -05:00
|
|
|
// Also update gen/tries.json when changing here.
|
2019-12-23 06:48:41 -05:00
|
|
|
match c {
|
|
|
|
0x09 | 0x0a | 0x0c | 0x0d | 0x20 => true,
|
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_c0_control(c: u8) -> bool {
|
2019-12-25 07:29:18 -05:00
|
|
|
// c >= 0 is always true.
|
|
|
|
c <= 0x1f
|
2019-12-23 06:48:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_control(c: u8) -> bool {
|
|
|
|
is_c0_control(c) || c >= 0x7f && c <= 0x9f
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_digit(c: u8) -> bool {
|
|
|
|
c >= b'0' && c <= b'9'
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_upper_hex_digit(c: u8) -> bool {
|
|
|
|
is_digit(c) || c >= b'A' && c <= b'F'
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_lower_hex_digit(c: u8) -> bool {
|
|
|
|
is_digit(c) || c >= b'a' && c <= b'f'
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_hex_digit(c: u8) -> bool {
|
|
|
|
is_upper_hex_digit(c) || is_lower_hex_digit(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_upper_alpha(c: u8) -> bool {
|
|
|
|
c >= b'A' && c <= b'Z'
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_lower_alpha(c: u8) -> bool {
|
|
|
|
c >= b'a' && c <= b'z'
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_alpha(c: u8) -> bool {
|
|
|
|
is_upper_alpha(c) || is_lower_alpha(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_alphanumeric(c: u8) -> bool {
|
|
|
|
is_digit(c) || is_alpha(c)
|
|
|
|
}
|