map a number to the corresponding character
map a character to its ASCII code point
Char( n )
Ord( s )
integer in the range 0..255
The procedures Char and Ord provide a bijective mapping between the characters that may appear in Maple strings and the integers in the range 1..255 via the (8-bit) ASCII character set. These procedures are similar to the homonymous operators in Pascal (and its descendents) and other languages in which characters are not an integer data type.
The Char(n) function, where n is an integer in the range 1..255, evaluates to the character (string of length one) whose ASCII code point is n. The number 0 is also accepted and, in this case, the empty string is returned.
The Ord(s) function maps characters to their ASCII code points. As a special case, Ord⁡ (in which the argument is the empty string) evaluates to 0. Given any nonempty string s, Ord⁡s is equivalent to Ord⁡s1, which evaluates to the ASCII code point of the character s1.
Note the relations Char( Ord( s ) ) = s[ 1 ], for any nonempty string s, and Ord( Char( n ) ) = n, for any integer n in the range 0..255. Thus, Char and Ord are nearly mutual inverses.
These functions are part of the StringTools package, and so they can be used in the form Char(..) only after executing the command with(StringTools). However, they can always be accessed through the long form of the command by using the form StringTools[Char](..).
All of the StringTools package commands treat strings as (null-terminated) sequences of 8-bit (ASCII) characters. Thus, there is no support for multibyte character encodings, such as unicode encodings.
Error, (in StringTools:-Char) integer argument is too large
Download Help Document