Char Data Type
Holds unsigned 32-bit (4-byte) Unicode character code points in the range 0–4,294,967,295.
Instructions
Char is short for “character”.
- Default value
- When you declare a variable of type
Charand do not initialize it, its default value is the character with a code point of zero (0). - Negation
Charis an unsigned type and thus cannot hold a negative value.- Automatic conversions
Charwidens toStringorSafeStringwithout risk of overflow.- Type characters
Charhas no type character.
Unicode characters
TODO
Character literal
You can give a code point for most Unicode characters directly in your code with a character literal.
You write a character literal with the character between backticks (`).
Some examples follow.
Dim letter As Char = `A`
Const backtick As Char = ```
Shared methods and properties
Char.Default As Char- Returns
%NUL. Char.Lower(c As Char, Optional #fmt As Format) As Char- Returns a lower-case letter if given an upper-case letter, or the given character if it is not a letter.
Char.Size As Int32- Returns the number of available bytes. This is always 4.
Char.Upper(c As Char, Optional #fmt As Format) As Char- Returns an upper-case letter if given a lower-case letter, or the given character if it is not a letter.
The methods that follow have three overloads each:
(1) a character (chr As Char),
(2) a string (str As String),
or (3) a safe string (str As SafeString).
For string types, each method gets the initial character of the given string.
But if the string is empty, the method raises an exception TBD.
Char.IsControl(chr As Char) As Boolean Char.IsControl(str As String) As Boolean Char.IsControl(str As SafeString) As Boolean- Returns true if given a control character, and false if given a different character.
Char.IsDigit(chr As Char) As Boolean Char.IsDigit(str As String) As Boolean Char.IsDigit(str As SafeString) As Boolean- Returns true if given a number between 0 and 9, and false if given a different character.
- See also
IsNumber. Char.IsLetter(chr As Char) As Boolean Char.IsLetter(str As String) As Boolean Char.IsLetter(str As SafeString) As Boolean- Returns true if given a letter, and false if given a different character.
Char.IsLower(chr As Char) As Boolean Char.IsLower(str As String) As Boolean Char.IsLower(str As SafeString) As Boolean- Returns true if given a lower-case letter, and false if given a different character.
- See also
IsUpper. Char.IsNumber(chr As Char) As Boolean Char.IsNumber(str As String) As Boolean Char.IsNumber(str As SafeString) As Boolean- Returns true if given a number or related character, and false if given a different character.
- See also
IsDigit. Char.IsPunctuation(chr As Char) As Boolean Char.IsPunctuation(str As String) As Boolean Char.IsPunctuation(str As SafeString) As Boolean- Returns true if given a punctuation character, and false if given a different character.
Char.IsSeparator(chr As Char) As Boolean Char.IsSeparator(str As String) As Boolean Char.IsSeparator(str As SafeString) As Boolean- Returns true if given a separator character, and false if given a different character.
- See also
IsWhitespace. Char.IsSymbol(chr As Char) As Boolean Char.IsSymbol(str As String) As Boolean Char.IsSymbol(str As SafeString) As Boolean- Returns true if given a symbol character, and false if given a different character.
Char.IsUpper(chr As Char) As Boolean Char.IsUpper(str As String) As Boolean Char.IsUpper(str As SafeString) As Boolean- Returns true if given an upper-case letter, and false if given a different character.
- See also
IsLower. Char.IsWhitespace(chr As Char) As Boolean Char.IsWhitespace(str As String) As Boolean Char.IsWhitespace(str As SafeString) As Boolean- Returns true if given a whitespace character, and false if given a different character.
- See also
IsSeparator. Char.UnicodeBlock(chr As Char) As UnicodeBlocks Char.UnicodeBlock(str As String) As UnicodeBlocks Char.UnicodeBlock(str As SafeString) As UnicodeBlocks- Returns an enumeration value of type
UnicodeBlocksthat is related to the Unicode block of the given character.