Char.Ascii
US-ASCII character support.
The following functions act only on US-ASCII code points, that is on the bytes in range [0x00
;0x7F
]. The functions can be safely used on UTF-8 encoded strings, they will of course only deal with US-ASCII related matters.
References.
is_digit c
is true
iff c
is an US-ASCII digit '0'
... '9'
, that is a byte in the range [0x30
;0x39
].
is_hex_digit c
is true
iff c
is an US-ASCII hexadecimal digit '0'
... '9'
, 'a'
... 'f'
, 'A'
... 'F'
, that is a byte in one of the ranges [0x30
;0x39
], [0x41
;0x46
], [0x61
;0x66
].
hex_digit_value c
is the numerical value of a digit that satisfies is_hex_digit
. Raises Invalid_argument
if is_hex_digit c
is false
.
lower_hex_digit n
is an hexadecimal digit for the integer n
truncated to its lowest 4 bits.
upper_hex_digit n
is an hexadecimal digit for the integer n
truncated to its lowest 4 bits.
is_valid c
is true
iff c
is an US-ASCII character, that is a byte in the range [0x00
;0x7F
].
is_upper c
is true
iff c
is an US-ASCII uppercase letter 'A'
... 'Z'
, that is a byte in the range [0x41
;0x5A
].
is_lower c
is true
iff c
is an US-ASCII lowercase letter 'a'
... 'z'
, that is a byte in the range [0x61
;0x7A
].
is_white c
is true
iff c
is an US-ASCII white space character, that is one of space ' '
(0x20
), tab '\t'
(0x09
), newline '\n'
(0x0A
), vertical tab (0x0B
), form feed (0x0C
), carriage return '\r'
(0x0D
).
is_blank c
is true
iff c
is an US-ASCII blank character, that is either space ' '
(0x20
) or tab '\t'
(0x09
).
is_graphic c
is true
iff c
is an US-ASCII graphic character that is a byte in the range [0x21
;0x7E
].
is_control c
is true
iff c
is an US-ASCII control character, that is a byte in the range [0x00
;0x1F
] or 0x7F
.
uppercase c
is c
with US-ASCII characters 'a'
to 'z'
mapped to 'A'
to 'Z'
.