Seed7 - The extensible programming language
Seed7 FAQ Manual Screenshots Examples Libraries Algorithms Download Links
Libraries AES ARC4 Array ASN.1 Bigfile Bigint Bigrat Bin32 Bin64 Bitdata Bitmapfont Bitset Bitsetof Boolean Browser Bstring Bytedata Cards Category CC config Cgi Cgi dialog Char Charsets Cipher Clib_file Color CLI Commands Complex Console Crc32 Deflate DES Dialog Dir Draw Duration Echo Editline Enable_input Enable_io Enable_output Encoding Environment External_file File File system Float Font Forloop Ftp Getf Gethttp Gethttps Graph Graph_file Gzip Hash Hashsetof Hmac Html_ent Httpserv Idxarray Image Inflate Inflate file Inifile Integer Keybd Line Listener LZW Make Math Msgdigest Null_file Osfiles Picture utility Pixmap_file Pixmapfont PKCS #1 Poll Process Progs Propertyfile Rational Reference Ref_list Scanfile Scanstri Set Shell Smtp Sockbase Socket SQL base Stdio Strifile String Stritext Subrange Tar Text Time TLS/SSL Triple DES Unicode Utf16 Utf8 Vectorfont 3D Vector Wildcard Window Wrinum X.509 Xmldom Xml_ent Zip
Libraries
Char Source Code
 previous   up   next 

Types
char
The type char describes Unicode characters encoded with UTF-32.

char

const type: char

The type char describes Unicode characters encoded with UTF-32. A char can also contain values, which are not Unicode, like EOF.


Constant Summary
char
EOF
Character representing end-of-file.

Operator Summary
char
(attr char) . first
Minimum value of char.
char
(attr char) . last
Maximum value of an Unicode character.
boolean
(in char: ch1) = (in char: ch2)
Check if two characters are equal.
boolean
(in char: ch1) <> (in char: ch2)
Check if two characters are not equal.
boolean
(in char: ch1) < (in char: ch2)
Check if ch1 is less than ch2.
boolean
(in char: ch1) > (in char: ch2)
Check if ch1 is greater than ch2.
boolean
(in char: ch1) <= (in char: ch2)
Check if ch1 is less than or equal to ch2.
boolean
(in char: ch1) >= (in char: ch2)
Check if ch1 is greater than or equal to ch2.
char
(attr char) conv (in integer: number)
Convert an integer number to a character.
char
(attr char) parse (in string: stri)
Convert a string with a length of 1 to a character.

Function Summary
integer
compare (in char: ch1, in char: ch2)
Compare two characters.
integer
hashCode (in char: ch)
Compute the hash value of a character.
integer
ord (in char: ch)
Get the ordinal number of a character.
char
chr (in integer: number)
Convert an integer number to a character.
char
succ (in char: ch)
Successor of a character.
char
pred (in char: ch)
Predecessor of a character.
string
str (in char: ch)
Create a string with one character.
char
upper (in char: ch)
Convert a character to upper case.
char
lower (in char: ch)
Convert a character to lower case.
boolean
isLetter (in char: ch)
Check whether ch is an alphabetic Unicode character.
integer
width (in char: ch)
Number of screen columns occupied by the Unicode character ch.
void
incr (inout char: ch)
Increment a character.
void
decr (inout char: ch)
Decrement a character.
char
rand (in char: low, in char: high)
Compute pseudo-random character in the range [low, high].
string
trimValue (attr char, in string: stri)
Trim a string such that it can be converted to char.
string
literal (in char: ch)
Conversion to a char literal.

Constant Detail

EOF

const char: EOF

Character representing end-of-file. EOF is not an Unicode character.


Operator Detail

. first

const char: (attr char) . first

Minimum value of char.


. last

const char: (attr char) . last

Maximum value of an Unicode character.


=

const func boolean: (in char: ch1) = (in char: ch2)

Check if two characters are equal.

Returns:
TRUE if both characters are equal, FALSE otherwise.

<>

const func boolean: (in char: ch1) <> (in char: ch2)

Check if two characters are not equal.

Returns:
FALSE if both characters are equal, TRUE otherwise.

<

const func boolean: (in char: ch1) < (in char: ch2)

Check if ch1 is less than ch2.

Returns:
TRUE if ch1 is less than than ch2, FALSE otherwise.

>

const func boolean: (in char: ch1) > (in char: ch2)

Check if ch1 is greater than ch2.

Returns:
TRUE if ch1 is greater than ch2, FALSE otherwise.

<=

const func boolean: (in char: ch1) <= (in char: ch2)

Check if ch1 is less than or equal to ch2.

Returns:
TRUE if ch1 is less than or equal to ch2, FALSE otherwise.

>=

const func boolean: (in char: ch1) >= (in char: ch2)

Check if ch1 is greater than or equal to ch2.

Returns:
TRUE if ch1 is greater than or equal to ch2, FALSE otherwise.

conv

const func char: (attr char) conv (in integer: number)

Convert an integer number to a character. For values between 0 and 1114111 a Unicode character is returned. For values between 1114112 and 1114368 a cursor or function key is returned. For -1 the value EOF is returned.

Returns:
a character which corresponds to the given integer.
Raises:
RANGE_ERROR - When the number does not fit into a 32-bit char.

parse

const func char: (attr char) parse (in string: stri)

Convert a string with a length of 1 to a character.

char parse "a"   returns 'a'
char parse " "   returns ' '
char parse "aa"  raises RANGE_ERROR
char parse "  "  raises RANGE_ERROR
char parse ""    raises RANGE_ERROR
Returns:
the first character of the string.
Raises:
RANGE_ERROR - When the length of the string is not 1.

Function Detail

compare

const func integer: compare (in char: ch1, in char: ch2)

Compare two characters.

Returns:
-1, 0 or 1 if the first argument is considered to be respectively less than, equal to, or greater than the second.

hashCode

const func integer: hashCode (in char: ch)

Compute the hash value of a character.

Returns:
the hash value.

ord

const func integer: ord (in char: ch)

Get the ordinal number of a character. For Unicode characters a value between 0 and 1114111 is returned. For cursor and function keys a value between 1114112 and 1114368 is returned. For EOF the value -1 is returned.

Returns:
the ordinal number of a character.

chr

const func char: chr (in integer: number)

Convert an integer number to a character. For values between 0 and 1114111 a Unicode character is returned. For values between 1114112 and 1114368 a cursor or function key is returned. For -1 the value EOF is returned.

Returns:
a character which corresponds to the given integer.
Raises:
RANGE_ERROR - When the number does not fit into a 32-bit char.

succ

const func char: succ (in char: ch)

Successor of a character.

Returns:
chr(ord(ch) + 1)

pred

const func char: pred (in char: ch)

Predecessor of a character.

Returns:
chr(ord(ch) - 1)

str

const func string: str (in char: ch)

Create a string with one character.

Returns:
a string with the character ch.

upper

const func char: upper (in char: ch)

Convert a character to upper case. The conversion uses the default Unicode case mapping, where each character is considered in isolation. Characters without case mapping are left unchanged. The mapping is independend from the locale. Individual character case mappings cannot be reversed, because some characters have multiple characters that map to them.

Returns:
the character converted to upper case.

lower

const func char: lower (in char: ch)

Convert a character to lower case. The conversion uses the default Unicode case mapping, where each character is considered in isolation. Characters without case mapping are left unchanged. The mapping is independend from the locale. Individual character case mappings cannot be reversed, because some characters have multiple characters that map to them.

Returns:
the character converted to lower case.

isLetter

const func boolean: isLetter (in char: ch)

Check whether ch is an alphabetic Unicode character.

Returns:
TRUE if ch is an alphabetic character, FALSE otherwise.

width

const func integer: width (in char: ch)

Number of screen columns occupied by the Unicode character ch. Non-spacing characters and control characters have width of 0.

Returns:
0,1 or 2 depending on the width occupied on a terminal.

incr

const proc: incr (inout char: ch)

Increment a character. This is equivalent to:

ch := succ(ch);

decr

const proc: decr (inout char: ch)

Decrement a character. This is equivalent to:

ch := pred(ch);

rand

const func char: rand (in char: low, in char: high)

Compute pseudo-random character in the range [low, high]. The random values are uniform distributed.

Returns:
a random character such that low <= rand(low, high) and rand(low, high) <= high holds.
Raises:
RANGE_ERROR - The range is empty (low > high holds).

trimValue

const func string: trimValue (attr char, in string: stri)

Trim a string such that it can be converted to char.

trimValue(char, " 1 ")             returns "1"
trimValue(char, "   ")             returns " "
trimValue(char, "\t ")             returns "\t"
trimValue(char, "")                returns ""
char parse trimValue(char, " 1 ")  returns '1'
char parse trimValue(char, "   ")  returns ' '
char parse trimValue(char, "\t ")  returns '\t'
char parse trimValue(char, "")     raises RANGE_ERROR
Returns:
the trimmed string.

literal

const func string: literal (in char: ch)

Conversion to a char literal.

Returns:
the character literal of ch.


 previous   up   next