Chapter Contents |
Previous |
Next |
Function Categories |
The character
type header files,
<ctype.h>
and
<lctype.h>
, define several macros that are
useful in the analysis of text data. Most of these macros enable you to determine
quickly the type of a character (whether it is alphabetic, numeric, punctuation,
and so on). These macros refer to an external array that is indexed by the
character itself, so they are generally much faster than functions that check
the character against a range or discrete list of values. Note that this
array is actually indexed by the character value plus 1, so the standard
EOF
value (-1) can be tested in a macro without
yielding a nonsense result.
EOF
yields
a 0 result for all of the macros because it is not defined as any of the character
types. Also, note that the results produced by most of these functions are
affected by the current locale's
LC_CTYPE
category, which may cause a different character type array to be used than
the one supplied for the default C locale. See Chapter 10, "Localization,"
in
SAS/C Library Reference, Volume 2 for details on locales.
The following are character type macros and functions:
Character Type Macros and Functions and Their Return Values lists the macros and functions defined in the character
type header files
<ctype.h>
and
<lctype.h>
. The library conforms to the ISO/ANSI specification
in that the macro arguments are evaluated only once. However, many implementations
do not conform to this specification. For maximum portability, beware of
the side effects of using expressions such as function calls and increment
or decrement operators. You should include
<ctype.h>
or
<lctype.h>
if you use any
of these macros; otherwise, the compiler generates a reference to a function
of the same name.
In Character Type Macros and Functions and Their Return Values,
functions marked with *
are not affected by
the locale's
LC_TYPE
category.
Note:
The
toupper
and
tolower
macros generate the value of
c
unchanged if it does not qualify for the conversion.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.