ctype.rs 817 B

123456789101112131415161718192021222324252627282930313233343536
  1. pub fn is_alnum(c: u8) -> bool {
  2. is_alpha(c) || is_digit(c)
  3. }
  4. pub fn is_alpha(c: u8) -> bool {
  5. is_lower(c) || is_upper(c)
  6. }
  7. pub fn is_blank(c: u8) -> bool {
  8. c == b' ' || c == b'\t'
  9. }
  10. pub fn is_cntrl(c: u8) -> bool {
  11. c <= 0x1f || c == 0x7f
  12. }
  13. pub fn is_digit(c: u8) -> bool {
  14. c >= b'0' && c <= b'9'
  15. }
  16. pub fn is_graph(c: u8) -> bool {
  17. c >= 0x21 && c <= 0x7e
  18. }
  19. pub fn is_lower(c: u8) -> bool {
  20. c >= b'a' && c <= b'z'
  21. }
  22. pub fn is_print(c: u8) -> bool {
  23. c >= 0x20 && c <= 0x7e
  24. }
  25. pub fn is_punct(c: u8) -> bool {
  26. is_graph(c) && !is_alnum(c)
  27. }
  28. pub fn is_space(c: u8) -> bool {
  29. c == b' ' || (c >= 0x9 && c <= 0xD)
  30. }
  31. pub fn is_upper(c: u8) -> bool {
  32. c >= b'A' && c <= b'Z'
  33. }
  34. pub fn is_xdigit(c: u8) -> bool {
  35. is_digit(c) || (c >= b'a' && c <= b'f') || (c >= b'A' && c <= b'F')
  36. }