
% Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are
% met:
%
%     - Redistributions of source code must retain the above copyright
%       notice, this list of conditions and the following disclaimer.
%
%     - Redistributions in binary form must reproduce the above copyright
%       notice, this list of conditions and the following disclaimer in
%       the documentation and/or other materials provided with the
%       distribution.
%
%     - Neither the name of The Numerical ALgorithms Group Ltd. nor the
%       names of its contributors may be used to endorse or promote products
%       derived from this software without specific prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
% IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
% TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
% OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES-- LOSS OF USE, DATA, OR
% PROFITS-- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.



The members of the domain \spadtype{Character} are values
representing letters, numerals and other text elements.
For more information on related topics, see
\xmpref{CharacterClass} and \xmpref{String}.

\xtc{
Characters can be obtained using \spadtype{String} notation.
}{
\spadcommand{chars := [char "a", char "A", char "X", char "8", char "+"] \bound{chars}}
}
\xtc{
Certain characters are available by name.
This is the blank character.
}{
\spadcommand{space()}
}
\xtc{
This is the quote that is used in strings.
}{
\spadcommand{quote()}
}
\xtc{
This is the underscore character which is used to allow quotes and
other special characters
within strings.
}{
\spadcommand{underscore()}
}
\xtc{
Characters are represented as integers in a machine-dependent way.
The integer value can be obtained using the \spadfunFrom{ord}{Character}
operation.
It is always true that \spad{char(ord c) = c} and \spad{ord(char i) = i},
provided that \spad{i} is in the range \spad{0..size()$Character-1}.
}{
\spadcommand{[ord c for c in chars] \free{chars}}
}

\xtc{
The \spadfunFrom{lowerCase}{Character} operation converts an upper case
letter to the corresponding lower case letter.
If the argument is not an upper case letter, then it is returned
unchanged.
}{
\spadcommand{[upperCase c for c in chars] \free{chars}}
}
\xtc{
Likewise, the \spadfunFrom{upperCase}{Character} operation converts lower
case letters to upper case.
}{
\spadcommand{[lowerCase c for c in chars] \free{chars}}
}

\xtc{
A number of tests are available to determine whether characters
belong to certain families.
}{
\spadcommand{[alphabetic? c for c in chars] \free{chars}}
}
\xtc{
}{
\spadcommand{[upperCase? c for c in chars] \free{chars}}
}
\xtc{
}{
\spadcommand{[lowerCase? c for c in chars] \free{chars}}
}
\xtc{
}{
\spadcommand{[digit? c for c in chars] \free{chars}}
}
\xtc{
}{
\spadcommand{[hexDigit? c for c in chars] \free{chars}}
}
\xtc{
}{
\spadcommand{[alphanumeric? c for c in chars] \free{chars}}
}
