1% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved. 2% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk. 3\newcommand{\CharacterXmpTitle}{Character} 4\newcommand{\CharacterXmpNumber}{9.8} 5% 6% ===================================================================== 7\begin{page}{CharacterXmpPage}{9.8 Character} 8% ===================================================================== 9\beginscroll 10 11% 12% 13% 14% 15% 16 17 18 19The members of the domain \spadtype{Character} are values 20representing letters, numerals and other text elements. 21For more information on related topics, see 22\downlink{`CharacterClass'}{CharacterClassXmpPage}\ignore{CharacterClass} and \downlink{`String'}{StringXmpPage}\ignore{String}. 23 24\xtc{ 25Characters can be obtained using \spadtype{String} notation. 26}{ 27\spadpaste{chars := [char "a", char "A", char "X", char "8", char "+"] \bound{chars}} 28} 29\xtc{ 30Certain characters are available by name. 31This is the blank character. 32}{ 33\spadpaste{space()} 34} 35\xtc{ 36This is the quote that is used in strings. 37}{ 38\spadpaste{quote()} 39} 40\xtc{ 41This is the escape character that allows quotes and other characters 42within strings. 43}{ 44\spadpaste{escape()} 45} 46\xtc{ 47Characters are represented as integers in a machine-dependent way. 48The integer value can be obtained using the \spadfunFrom{ord}{Character} 49operation. 50It is always true that \spad{char(ord c) = c} and \spad{ord(char i) = i}, 51provided that \spad{i} is in the range \spad{0..size()\$Character-1}. 52}{ 53\spadpaste{[ord c for c in chars] \free{chars}} 54} 55 56\xtc{ 57The \spadfunFrom{lowerCase}{Character} operation converts an upper case 58letter to the corresponding lower case letter. 59If the argument is not an upper case letter, then it is returned 60unchanged. 61}{ 62\spadpaste{[upperCase c for c in chars] \free{chars}} 63} 64\xtc{ 65Likewise, the \spadfunFrom{upperCase}{Character} operation converts lower 66case letters to upper case. 67}{ 68\spadpaste{[lowerCase c for c in chars] \free{chars}} 69} 70 71\xtc{ 72A number of tests are available to determine whether characters 73belong to certain families. 74}{ 75\spadpaste{[alphabetic? c for c in chars] \free{chars}} 76} 77\xtc{ 78}{ 79\spadpaste{[upperCase? c for c in chars] \free{chars}} 80} 81\xtc{ 82}{ 83\spadpaste{[lowerCase? c for c in chars] \free{chars}} 84} 85\xtc{ 86}{ 87\spadpaste{[digit? c for c in chars] \free{chars}} 88} 89\xtc{ 90}{ 91\spadpaste{[hexDigit? c for c in chars] \free{chars}} 92} 93\xtc{ 94}{ 95\spadpaste{[alphanumeric? c for c in chars] \free{chars}} 96} 97\endscroll 98\autobuttons 99\end{page} 100% 101