StringTools - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Names and Strings : StringTools Package : Miscellaneous Utilities : StringTools/Char

StringTools

  

Char

  

map a number to the corresponding character

  

Ord

  

map a character to its ASCII code point

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

Char( n )

Ord( s )

Parameters

n

-

integer in the range 0..255

s

-

Maple string

Description

• 

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, Ords is equivalent to Ords1, 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](..).

Examples

withStringTools:

Ord

0

(1)

Orda

97

(2)

Ord4

52

(3)

Ord40a

52

(4)

mapOrd,Explodeabcdefghijklmnopqrstuvwxyz

97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122

(5)

Char0

(6)

Char32

(7)

Char65

A

(8)

Char127



(9)

Char300

Error, (in StringTools:-Char) integer argument is too large

evalbcatopmapChar,`$`1..255=convert`$`1..255,'bytes'

true

(10)

See Also

cat

convert

map

op

seq

string

StringTools

StringTools[Explode]

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam