package tablecloth-native
Library
Module
Module type
Parameter
Class
Class type
Functions for working with characters. Character literals are enclosed in 'a'
pair of single quotes.
Convert to the corresponding ASCII code point
cp
.
cp
: https://en.wikipedia.org/wiki/Code_point
toCode 'A' = 65
toCode 'B' = 66
toCode 'þ' = 254
Convert an ASCII code point
cp
to a character.
fromCode 65 = Some 'A'
fromCode 66 = Some 'B'
fromCode 3000 = None
fromCode (-1) = None
The full range of extended ASCII is from 0
to 255
. For numbers outside that range, you get None
.
cp
: https://en.wikipedia.org/wiki/Code_point
Convert a character into a string. toString 'A' = "A"
toString '{' = "{"
toString '7' = "7"
Converts a string to character. Returns None when the string isn't of length one. fromString "A" = Some 'A'
fromString " " = Some ' '
fromString "" = None
fromString "abc" = None
fromString " a" = None
Converts a digit character to its corresponding integer. Returns None when the character isn't a digit. toDigit "7" = Some 7
toDigit "0" = Some 0
toDigit "A" = None
toDigit "" = None
Converts an ASCII character to lower case, preserving non alphabetic ASCII characters. toLowercase 'A' = 'a'
toLowercase 'B' = 'b'
toLowercase '7' = '7'
Convert an ASCII character to upper case, preserving non alphabetic ASCII characters. toUppercase 'a' = 'A'
toUppercase 'b' = 'B'
toUppercase '7' = '7'
Detect lower case ASCII characters.
isLowercase 'a' = true
isLowercase 'b' = true
...
isLowercase 'z' = true
isLowercase '0' = false
isLowercase 'A' = false
isLowercase '-' = false
isLowercase 'ã' = false
Detect upper case ASCII characters.
isUppercase 'A' = true
isUppercase 'B' = true
...
isUppercase 'Z' = true
isUppercase '0' = false
isUppercase 'Ý' = false
isUppercase '-' = false
Detect upper and lower case ASCII alphabetic characters.
isLetter 'a' = true
isLetter 'b' = true
isLetter 'E' = true
isLetter 'Y' = true
isLetter '0' = false
isLetter 'ý' = false
isLetter '-' = false
Detect when a character is a number
isDigit '0' = true
isDigit '1' = true
... isDigit '9' = true
isDigit 'a' = false
isDigit 'b' = false
isDigit 'ý' = false
Detect upper case, lower case and digit ASCII characters.
isAlphanumeric 'a' = true
isAlphanumeric 'b' = true
isAlphanumeric 'E' = true
isAlphanumeric 'Y' = true
isAlphanumeric '0' = true
isAlphanumeric '7' = true
isAlphanumeric '-' = false
Detect if a character is a printable
character https://en.wikipedia.org/wiki/ASCII#Printable_characters
isPrintable ' ' = true
Detect ' ', '\t', '\r' or '\n' characters.
isWhitespace ' ' = true
isWhitespace 'b' = false