2000-06-26 23:59:24 +00:00
|
|
|
\section{\module{curses.ascii} ---
|
2000-06-28 22:03:29 +00:00
|
|
|
Utilities for ASCII characters}
|
2000-06-26 23:59:24 +00:00
|
|
|
|
|
|
|
\declaremodule{standard}{curses.ascii}
|
2000-06-28 22:03:29 +00:00
|
|
|
\modulesynopsis{Constants and set-membership functions for
|
|
|
|
\ASCII{} characters.}
|
2000-06-26 23:59:24 +00:00
|
|
|
\moduleauthor{Eric S. Raymond}{esr@thyrsus.com}
|
|
|
|
\sectionauthor{Eric S. Raymond}{esr@thyrsus.com}
|
|
|
|
|
2000-06-30 16:06:19 +00:00
|
|
|
\versionadded{2.0}
|
2000-06-26 23:59:24 +00:00
|
|
|
|
2000-06-28 22:03:29 +00:00
|
|
|
The \module{curses.ascii} module supplies name constants for
|
|
|
|
\ASCII{} characters and functions to test membership in various
|
|
|
|
\ASCII{} character classes. The constants supplied are names for
|
|
|
|
control characters as follows:
|
|
|
|
|
|
|
|
\begin{tableii}{l|l}{constant}{Name}{Meaning}
|
|
|
|
\lineii{NUL}{}
|
|
|
|
\lineii{SOH}{Start of heading, console interrupt}
|
|
|
|
\lineii{STX}{Start of text}
|
|
|
|
\lineii{ETX}{Ennd of text}
|
|
|
|
\lineii{EOT}{End of transmission}
|
|
|
|
\lineii{ENQ}{Enquiry, goes with \constant{ACK} flow control}
|
|
|
|
\lineii{ACK}{Acknowledgement}
|
|
|
|
\lineii{BEL}{Bell}
|
|
|
|
\lineii{BS}{Backspace}
|
|
|
|
\lineii{TAB}{Tab}
|
|
|
|
\lineii{HT}{Alias for \constant{TAB}: ``Horizontal tab''}
|
|
|
|
\lineii{LF}{Line feed}
|
|
|
|
\lineii{NL}{Alias for \constant{LF}: ``New line''}
|
|
|
|
\lineii{VT}{Vertical tab}
|
|
|
|
\lineii{FF}{Form feed}
|
|
|
|
\lineii{CR}{Carriage return}
|
|
|
|
\lineii{SO}{Shift-out, begin alternate character set}
|
|
|
|
\lineii{SI}{Shift-in, resume default character set}
|
|
|
|
\lineii{DLE}{Data-link escape}
|
|
|
|
\lineii{DC1}{XON, for flow control}
|
|
|
|
\lineii{DC2}{Device control 2, block-mode flow control}
|
|
|
|
\lineii{DC3}{XOFF, for flow control}
|
|
|
|
\lineii{DC4}{Device control 4}
|
|
|
|
\lineii{NAK}{Negative acknowledgement}
|
|
|
|
\lineii{SYN}{Synchronous idle}
|
|
|
|
\lineii{ETB}{End transmission block}
|
|
|
|
\lineii{CAN}{Cancel}
|
|
|
|
\lineii{EM}{End of medium}
|
|
|
|
\lineii{SUB}{Substitute}
|
|
|
|
\lineii{ESC}{Escape}
|
|
|
|
\lineii{FS}{File separator}
|
|
|
|
\lineii{GS}{Group separator}
|
|
|
|
\lineii{RS}{Record separator, block-mode terminator}
|
|
|
|
\lineii{US}{Unit separator}
|
|
|
|
\lineii{SP}{Space}
|
|
|
|
\lineii{DEL}{Delete}
|
|
|
|
\end{tableii}
|
|
|
|
|
|
|
|
Note that many of these have little practical use in modern usage.
|
|
|
|
|
|
|
|
The module supplies the following functions, patterned on those in the
|
|
|
|
standard C library:
|
2000-06-26 23:59:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
\begin{funcdesc}{isalnum}{c}
|
2000-06-28 22:03:29 +00:00
|
|
|
Checks for an \ASCII{} alphanumeric character; it is equivalent to
|
|
|
|
\samp{isalpha(\var{c}) or isdigit(\var{c})}.
|
2000-06-26 23:59:24 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{isalpha}{c}
|
2000-06-28 22:03:29 +00:00
|
|
|
Checks for an \ASCII{} alphabetic character; it is equivalent to
|
|
|
|
\samp{isupper(\var{c}) or islower(\var{c})}.
|
2000-06-26 23:59:24 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{isascii}{c}
|
2000-06-28 22:03:29 +00:00
|
|
|
Checks for a character value that fits in the 7-bit \ASCII{} set.
|
2000-06-26 23:59:24 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{isblank}{c}
|
2000-06-28 22:03:29 +00:00
|
|
|
Checks for an \ASCII{} whitespace character.
|
2000-06-26 23:59:24 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{iscntrl}{c}
|
2000-06-28 22:03:29 +00:00
|
|
|
Checks for an \ASCII{} control character (in the range 0x00 to 0x1f).
|
2000-06-26 23:59:24 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{isdigit}{c}
|
2000-06-28 22:03:29 +00:00
|
|
|
Checks for an \ASCII{} decimal digit, \character{0} through
|
|
|
|
\character{9}. This is equivalent to \samp{\var{c} in string.digits}.
|
2000-06-26 23:59:24 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{isgraph}{c}
|
2000-06-28 22:03:29 +00:00
|
|
|
Checks for \ASCII{} any printable character except space.
|
2000-06-26 23:59:24 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{islower}{c}
|
2000-06-28 22:03:29 +00:00
|
|
|
Checks for an \ASCII{} lower-case character.
|
2000-06-26 23:59:24 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{isprint}{c}
|
2000-06-28 22:03:29 +00:00
|
|
|
Checks for any \ASCII{} printable character including space.
|
2000-06-26 23:59:24 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{ispunct}{c}
|
2000-06-28 22:03:29 +00:00
|
|
|
Checks for any printable \ASCII{} character which is not a space or an
|
2000-06-26 23:59:24 +00:00
|
|
|
alphanumeric character.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{isspace}{c}
|
2000-06-28 22:03:29 +00:00
|
|
|
Checks for \ASCII{} white-space characters; space, tab, line feed,
|
2000-06-26 23:59:24 +00:00
|
|
|
carriage return, form feed, horizontal tab, vertical tab.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{isupper}{c}
|
2000-06-28 22:03:29 +00:00
|
|
|
Checks for an \ASCII{} uppercase letter.
|
2000-06-26 23:59:24 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{isxdigit}{c}
|
2000-06-28 22:03:29 +00:00
|
|
|
Checks for an \ASCII{} hexadecimal digit. This is equivalent to
|
|
|
|
\samp{\var{c} in string.hexdigits}.
|
2000-06-26 23:59:24 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{isctrl}{c}
|
2000-06-28 22:03:29 +00:00
|
|
|
Checks for an \ASCII{} control character (ordinal values 0 to 31).
|
2000-06-26 23:59:24 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{ismeta}{c}
|
2000-06-28 22:03:29 +00:00
|
|
|
Checks for a non-\ASCII{} character (ordinal values 0x80 and above).
|
2000-06-26 23:59:24 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
These functions accept either integers or strings; when the argument
|
2000-06-28 22:03:29 +00:00
|
|
|
is a string, it is first converted using the built-in function
|
|
|
|
\function{ord()}.
|
2000-06-26 23:59:24 +00:00
|
|
|
|
|
|
|
Note that all these functions check ordinal bit values derived from the
|
|
|
|
first character of the string you pass in; they do not actually know
|
|
|
|
anything about the host machine's character encoding. For functions
|
|
|
|
that know about the character encoding (and handle
|
2000-06-28 22:03:29 +00:00
|
|
|
internationalization properly) see the \refmodule{string} module.
|
2000-06-26 23:59:24 +00:00
|
|
|
|
|
|
|
The following two functions take either a single-character string or
|
|
|
|
integer byte value; they return a value of the same type.
|
|
|
|
|
|
|
|
\begin{funcdesc}{ascii}{c}
|
2000-06-28 22:03:29 +00:00
|
|
|
Return the ASCII value corresponding to the low 7 bits of \var{c}.
|
2000-06-26 23:59:24 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{ctrl}{c}
|
|
|
|
Return the control character corresponding to the given character
|
2000-06-28 22:03:29 +00:00
|
|
|
(the character bit value is bitwise-anded with 0x1f).
|
2000-06-26 23:59:24 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{alt}{c}
|
|
|
|
Return the 8-bit character corresponding to the given ASCII character
|
2000-06-28 22:03:29 +00:00
|
|
|
(the character bit value is bitwise-ored with 0x80).
|
2000-06-26 23:59:24 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
The following function takes either a single-character string or
|
2000-06-28 22:03:29 +00:00
|
|
|
integer value; it returns a string.
|
2000-06-26 23:59:24 +00:00
|
|
|
|
|
|
|
\begin{funcdesc}{unctrl}{c}
|
2000-06-28 22:03:29 +00:00
|
|
|
Return a string representation of the \ASCII{} character \var{c}. If
|
|
|
|
\var{c} is printable, this string is the character itself. If the
|
|
|
|
character is a control character (0x00-0x1f) the string consists of a
|
|
|
|
caret (\character{\^}) followed by the corresponding uppercase letter.
|
|
|
|
If the character is an \ASCII{} delete (0x7f) the string is
|
|
|
|
\code{'\^{}?'}. If the character has its meta bit (0x80) set, the meta
|
|
|
|
bit is stripped, the preceding rules applied, and
|
|
|
|
\character{!} prepended to the result.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{datadesc}{controlnames}
|
|
|
|
A 33-element string array that contains the \ASCII{} mnemonics for the
|
|
|
|
thirty-two \ASCII{} control characters from 0 (NUL) to 0x1f (US), in
|
|
|
|
order, plus the mnemonic \samp{SP} for the space character.
|
|
|
|
\end{datadesc}
|