ctoolbox/formats/eite/util/
ascii.rs1pub fn ascii_is_digit(b: u8) -> bool {
6 b.is_ascii_digit()
7}
8pub fn ascii_is_alpha(b: u8) -> bool {
9 b.is_ascii_alphabetic()
10}
11pub fn ascii_is_alphanum(b: u8) -> bool {
12 b.is_ascii_alphanumeric()
13}
14pub fn ascii_is_letter_lower(b: u8) -> bool {
15 (char::from(b)).is_ascii_lowercase()
16}
17pub fn ascii_is_letter(b: u8) -> bool {
18 (char::from(b)).is_ascii_alphabetic()
19}
20
21pub fn is_ascii_byte(b: u8) -> bool {
23 b <= 0x7F
24}
25
26pub fn ascii_is_printable(b: u8) -> bool {
28 (32..=126).contains(&b)
29}
30
31pub fn ascii_is_space(b: u8) -> bool {
33 b == 0x20
34}
35
36pub fn ascii_is_newline(b: u8) -> bool {
38 b == 10 || b == 13
39}
40
41pub fn ascii_is_letter_upper(b: u8) -> bool {
43 b.is_ascii_uppercase()
44}
45
46pub fn ascii_is_letter_2(b: u8) -> bool {
48 ascii_is_letter(b)
49}
50
51pub fn ascii_is_alphanum_2(b: u8) -> bool {
53 ascii_is_alphanum(b)
54}
55
56pub fn crlf() -> Vec<u8> {
58 vec![13, 10]
59}
60
61#[cfg(test)]
62mod tests {
63 use super::*;
64
65 #[crate::ctb_test]
66 fn test_ascii_helpers() {
67 assert!(ascii_is_digit(b'5'));
68 assert!(ascii_is_alphanum(b'A'));
69 assert!(ascii_is_letter_lower(b'z'));
70 }
71}