i32.is_digit #
line 24func i32.is_digit(self: i32) -> i32
Whether self is an ASCII digit, 0 through 9.
Source
func i32.is_digit(self: i32) -> i32 { return self >= 48 && self <= 57; }
Reed's standard library. Imported with use std.ascii; not on disk.
| i32.is_digit | Whether self is an ASCII digit, 0 through 9. |
| i32.is_alpha | Whether self is an ASCII letter, A-Z or a-z. |
| i32.is_alnum | Whether self is an ASCII letter or digit. |
| i32.is_space | Whether self is an ASCII whitespace character. |
| i32.is_upper | Whether self is an ASCII uppercase letter. |
| i32.is_lower | Whether self is an ASCII lowercase letter. |
| i32.is_hex_digit | Whether self is an ASCII hexadecimal digit: 0-9, a-f, or A-F. |
| i32.is_punct | Whether self is an ASCII punctuation character. |
| i32.is_print | Whether self is a printable ASCII character, space through ~. |
| i32.is_control | Whether self is an ASCII control character: 0-31 or 127 (delete). |
| i32.is_ascii | Whether self is a 7-bit ASCII byte at all. |
| i32.to_lower | Converts an ASCII uppercase letter to lowercase, leaving everything else unchanged. |
| i32.to_upper | Converts an ASCII lowercase letter to uppercase, leaving everything else unchanged. |
| i32.digit_value | The numeric value of an ASCII digit in any base up to 36. |
| i32.digit_char | The lowercase ASCII character representing a digit value in 0..=35. |
| i32.cmp_ignore_case | Compares two ASCII characters ignoring case. |
func i32.is_digit(self: i32) -> i32
Whether self is an ASCII digit, 0 through 9.
func i32.is_digit(self: i32) -> i32 { return self >= 48 && self <= 57; }
func i32.is_alpha(self: i32) -> i32
Whether self is an ASCII letter, A-Z or a-z.
func i32.is_alpha(self: i32) -> i32 { return (self >= 65 && self <= 90) || (self >= 97 && self <= 122); }
func i32.is_alnum(self: i32) -> i32
Whether self is an ASCII letter or digit.
func i32.is_alnum(self: i32) -> i32 { return self.is_alpha() || self.is_digit(); }
func i32.is_space(self: i32) -> i32
Whether self is an ASCII whitespace character.
The set is space, tab, newline, carriage return, form feed, and vertical tab -- the same six characters C's isspace recognizes.
func i32.is_space(self: i32) -> i32 { return self == 32 || (self >= 9 && self <= 13); }
func i32.is_upper(self: i32) -> i32
Whether self is an ASCII uppercase letter.
func i32.is_upper(self: i32) -> i32 { return self >= 65 && self <= 90; }
func i32.is_lower(self: i32) -> i32
Whether self is an ASCII lowercase letter.
func i32.is_lower(self: i32) -> i32 { return self >= 97 && self <= 122; }
func i32.is_hex_digit(self: i32) -> i32
Whether self is an ASCII hexadecimal digit: 0-9, a-f, or A-F.
func i32.is_hex_digit(self: i32) -> i32 { return self.is_digit() || (self >= 97 && self <= 102) || (self >= 65 && self <= 70); }
func i32.is_punct(self: i32) -> i32
Whether self is an ASCII punctuation character.
Every printable non-alphanumeric, non-space character in !..~.
func i32.is_punct(self: i32) -> i32 { return self >= 33 && self <= 126 && !self.is_alnum(); }
func i32.is_print(self: i32) -> i32
Whether self is a printable ASCII character, space through ~.
func i32.is_print(self: i32) -> i32 { return self >= 32 && self <= 126; }
func i32.is_control(self: i32) -> i32
Whether self is an ASCII control character: 0-31 or 127 (delete).
func i32.is_control(self: i32) -> i32 { return (self >= 0 && self <= 31) || self == 127; }
func i32.is_ascii(self: i32) -> i32
Whether self is a 7-bit ASCII byte at all.
func i32.is_ascii(self: i32) -> i32 { return self >= 0 && self <= 127; }
func i32.to_lower(self: i32) -> i32
Converts an ASCII uppercase letter to lowercase, leaving everything else unchanged.
Bytes above 127 pass through untouched: see this module's scope note.
func i32.to_lower(self: i32) -> i32 { return self.is_upper() ? self + 32 : self; }
func i32.to_upper(self: i32) -> i32
Converts an ASCII lowercase letter to uppercase, leaving everything else unchanged.
func i32.to_upper(self: i32) -> i32 { return self.is_lower() ? self - 32 : self; }
func i32.digit_value(self: i32) -> i32
The numeric value of an ASCII digit in any base up to 36.
Accepts 0-9 and both cases of a-z. Returns -1 -- not 0 -- for anything that is not a digit, since 0 is a perfectly good digit value and the two must be distinguishable by a caller parsing a number.
func i32.digit_value(self: i32) -> i32 { if (self.is_digit()) { return self - 48; } if (self >= 97 && self <= 122) { return self - 87; } if (self >= 65 && self <= 90) { return self - 55; } return -1; }
func i32.digit_char(self: i32) -> i32
The lowercase ASCII character representing a digit value in 0..=35.
The inverse of digit_value. Returns -1 for a value outside the range, matching that function's convention for "not representable".
func i32.digit_char(self: i32) -> i32 { if (self < 0 || self > 35) { return -1; } return self < 10 ? self + 48 : self + 87; }
func i32.cmp_ignore_case(self: i32, rhs: i32) -> i32
Compares two ASCII characters ignoring case.
func i32.cmp_ignore_case(self: i32, rhs: i32) -> i32 { return self.to_lower() - rhs.to_lower(); }