Char
Edit on GitHubUtilities for working with the Char type.
The Char type represents a single Unicode scalar value.
Added in 0.3.0
No other changes yet.
Types
Type declarations included in the Char module.
Char.Encoding
Added in 0.7.0
No other changes yet.
Byte encodings
Values
Functions and constants included in the Char module.
Char.min
Added in 0.3.0
No other changes yet.
The minimum valid Unicode scalar value.
Char.max
Added in 0.3.0
No other changes yet.
The maximum valid Unicode scalar value.
Char.isValid
Added in 0.3.0
No other changes yet.
Determines whether the given character code is a valid Unicode scalar value.
Parameters:
param | type | description |
---|---|---|
charCode |
Number |
The number to check |
Returns:
type | description |
---|---|
Bool |
true if the number refers to a valid Unicode scalar value or false otherwise |
Examples:
Char.code
Added in 0.3.0
No other changes yet.
Determines the Unicode scalar value for a character.
Parameters:
param | type | description |
---|---|---|
char |
Char |
The character |
Returns:
type | description |
---|---|
Number |
The Unicode scalar value for the given character |
Examples:
Char.fromCode
Added in 0.3.0
No other changes yet.
Creates a character from the given Unicode scalar value.
Parameters:
param | type | description |
---|---|---|
usv |
Number |
The Unicode scalar value |
Returns:
type | description |
---|---|
Char |
The character for the given Unicode scalar value |
Throws:
InvalidArgument(String)
- When the Unicode scalar value is invalid
Examples:
Char.succ
Added in 0.3.0
No other changes yet.
Returns the next valid character by Unicode scalar value.
Parameters:
param | type | description |
---|---|---|
char |
Char |
The character |
Returns:
type | description |
---|---|
Char |
The next valid character by Unicode scalar value |
Throws:
Failure(String)
- When the input character is the maximum valid Unicode scalar value
Examples:
Char.pred
Added in 0.3.0
No other changes yet.
Returns the previous valid character by Unicode scalar value.
Parameters:
param | type | description |
---|---|---|
char |
Char |
The character |
Returns:
type | description |
---|---|
Char |
The previous valid character by Unicode scalar value |
Throws:
Failure(String)
- When the input character is the minimum valid Unicode scalar value
Examples:
Char.toString
Added in 0.3.0
No other changes yet.
Converts the given character to a string.
Parameters:
param | type | description |
---|---|---|
char |
Char |
The character to convert |
Returns:
type | description |
---|---|
String |
A string containing the given character |
Examples:
Char.encodedLength
Added in 0.7.0
No other changes yet.
Returns the byte count of a character if encoded in the given encoding.
Parameters:
param | type | description |
---|---|---|
encoding |
Encoding |
The encoding to check |
char |
Char |
The character |
Returns:
type | description |
---|---|
Number |
The byte count of the character in the given encoding |
Examples:
Char.(<)
Added in 0.6.0
No other changes yet.
Checks if the first character is less than the second character by Unicode scalar value.
Parameters:
param | type | description |
---|---|---|
x |
Char |
The first character |
y |
Char |
The second character |
Returns:
type | description |
---|---|
Bool |
true if the first character is less than the second character or false otherwise |
Examples:
Char.(<=)
Added in 0.6.0
No other changes yet.
Checks if the first character is less than or equal to the second character by Unicode scalar value.
Parameters:
param | type | description |
---|---|---|
x |
Char |
The first character |
y |
Char |
The second character |
Returns:
type | description |
---|---|
Bool |
true if the first character is less than or equal to the second character or false otherwise |
Examples:
Char.(>)
Added in 0.6.0
No other changes yet.
Checks if the first character is greater than the second character by Unicode scalar value.
Parameters:
param | type | description |
---|---|---|
x |
Char |
The first character |
y |
Char |
The second character |
Returns:
type | description |
---|---|
Bool |
true if the first character is greater than the second character or false otherwise |
Examples:
Char.(>=)
Added in 0.6.0
No other changes yet.
Checks if the first character is greater than or equal to the second character by Unicode scalar value.
Parameters:
param | type | description |
---|---|---|
x |
Char |
The first character |
y |
Char |
The second character |
Returns:
type | description |
---|---|
Bool |
true if the first character is greater than or equal to the second character or false otherwise |
Examples:
Char.Ascii
Utilities for working with ASCII characters.
Added in 0.7.0
No other changes yet.
Values
Functions and constants included in the Char.Ascii module.
Char.Ascii.min
Added in 0.7.0
No other changes yet.
The minimum valid ASCII character code.
Char.Ascii.max
Added in 0.7.0
No other changes yet.
The maximum valid ASCII character code.
Char.Ascii.isValid
Added in 0.7.0
No other changes yet.
Checks if the character is a valid ASCII character.
Parameters:
param | type | description |
---|---|---|
char |
Char |
The character to check |
Returns:
type | description |
---|---|
Bool |
true if the character is an ASCII character or false otherwise |
Examples:
Char.Ascii.isDigit
Added in 0.7.0
version | changes |
---|---|
0.6.0 | Originally `Char.isAsciiDigit` |
Checks if the character is an ASCII digit.
Parameters:
param | type | description |
---|---|---|
char |
Char |
The character to check |
Returns:
type | description |
---|---|
Bool |
true if the character is an ASCII digit or false otherwise |
Examples:
Char.Ascii.isAlpha
Added in 0.7.0
version | changes |
---|---|
0.6.0 | Originally `Char.isAsciiAlpha` |
Checks if the character is an ASCII alphabetical character.
Parameters:
param | type | description |
---|---|---|
char |
Char |
The character to check |
Returns:
type | description |
---|---|
Bool |
true if the character is an ASCII alphabetical or false otherwise |
Examples:
Char.Ascii.isControl
Added in 0.7.0
No other changes yet.
Checks if the character is an ASCII control character.
Parameters:
param | type | description |
---|---|---|
char |
Char |
The character to check |
Returns:
type | description |
---|---|
Bool |
true if the character is an ASCII control character or false otherwise |
Examples:
Char.Ascii.isWhitespace
Added in 0.7.0
No other changes yet.
Checks if the character is an ASCII whitespace character.
Parameters:
param | type | description |
---|---|---|
char |
Char |
The character to check |
Returns:
type | description |
---|---|
Bool |
true if the character is an ASCII whitespace character or false otherwise |
Examples:
Char.Ascii.isPunctuation
Added in 0.7.0
No other changes yet.
Checks if the character is an ASCII punctuation character.
Parameters:
param | type | description |
---|---|---|
char |
Char |
The character to check |
Returns:
type | description |
---|---|
Bool |
true if the character is an ASCII punctuation character or false otherwise |
Examples:
Char.Ascii.isGraphic
Added in 0.7.0
No other changes yet.
Checks if the character is an ASCII graphic character.
Parameters:
param | type | description |
---|---|---|
char |
Char |
The character to check |
Returns:
type | description |
---|---|
Bool |
true if the character is an ASCII graphic character or false otherwise |
Examples:
Char.Ascii.toLowercase
Added in 0.7.0
version | changes |
---|---|
0.6.0 | Originally `Char.toAsciiLowercase` |
Converts the character to ASCII lowercase if it is an ASCII uppercase character.
Parameters:
param | type | description |
---|---|---|
char |
Char |
The character to convert |
Returns:
type | description |
---|---|
Char |
The lowercased character |
Examples:
Char.Ascii.toUppercase
Added in 0.7.0
version | changes |
---|---|
0.6.0 | Originally `Char.toAsciiUppercase` |
Converts the character to ASCII uppercase if it is an ASCII lowercase character.
Parameters:
param | type | description |
---|---|---|
char |
Char |
The character to convert |
Returns:
type | description |
---|---|
Char |
The uppercased character |
Examples: