134 lines
7.2 KiB
HTML
134 lines
7.2 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
|
||
|
<!Converted with LaTeX2HTML 0.6.5 (Tue Nov 15 1994) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
|
||
|
<HEAD>
|
||
|
<TITLE>13.3. Character Construction and Selection</TITLE>
|
||
|
</HEAD>
|
||
|
<BODY>
|
||
|
<meta name="description" value=" Character Construction and Selection">
|
||
|
<meta name="keywords" value="clm">
|
||
|
<meta name="resource-type" value="document">
|
||
|
<meta name="distribution" value="global">
|
||
|
<P>
|
||
|
<b>Common Lisp the Language, 2nd Edition</b>
|
||
|
<BR> <HR><A NAME=tex2html3250 HREF="node139.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html3248 HREF="node135.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html3242 HREF="node137.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html3252 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html3253 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
||
|
<B> Next:</B> <A NAME=tex2html3251 HREF="node139.html"> Character Conversions</A>
|
||
|
<B>Up:</B> <A NAME=tex2html3249 HREF="node135.html"> Characters</A>
|
||
|
<B> Previous:</B> <A NAME=tex2html3243 HREF="node137.html"> Predicates on Characters</A>
|
||
|
<HR> <P>
|
||
|
<H1><A NAME=SECTION001730000000000000000>13.3. Character Construction and Selection</A></H1>
|
||
|
<P>
|
||
|
These functions may be used to extract attributes of a character
|
||
|
and to construct new characters.
|
||
|
<P>
|
||
|
<BR><b>[Function]</b><BR>
|
||
|
<tt>char-code <i>char</i></tt><P>The argument <i>char</i> must be a character object.
|
||
|
<tt>char-code</tt> returns the code attribute of the character object;
|
||
|
this will be a non-negative integer less than the (normal) value of
|
||
|
the variable <tt>char-code-limit</tt>.
|
||
|
<P>
|
||
|
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
|
||
|
This is usually what you need in order to treat a character as an
|
||
|
index into a vector. The length of the vector should then be
|
||
|
equal to <tt>char-code-limit</tt>. Be careful how you initialize this
|
||
|
vector; remember that you cannot necessarily
|
||
|
expect all non-negative integers less than
|
||
|
<tt>char-code-limit</tt> to be valid character codes.
|
||
|
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
|
||
|
<P>
|
||
|
<img align=bottom alt="old_change_begin" src="gif/old_change_begin.gif"><br>
|
||
|
<BR><b>[Function]</b><BR>
|
||
|
<tt>char-bits <i>char</i></tt><P>The argument <i>char</i> must be a character object.
|
||
|
<tt>char-bits</tt> returns the bits attribute of the character object;
|
||
|
this will be a non-negative integer less than the (normal) value of
|
||
|
the variable <tt>char-bits-limit</tt>.
|
||
|
<br><img align=bottom alt="old_change_end" src="gif/old_change_end.gif">
|
||
|
<P>
|
||
|
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
|
||
|
X3J13 voted in March 1989 (CHARACTER-PROPOSAL) <A NAME=14846> </A>
|
||
|
to eliminate <tt>char-bits</tt>.
|
||
|
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
|
||
|
<P>
|
||
|
<img align=bottom alt="old_change_begin" src="gif/old_change_begin.gif"><br>
|
||
|
<BR><b>[Function]</b><BR>
|
||
|
<tt>char-font <i>char</i></tt><P>The argument <i>char</i> must be a character object.
|
||
|
<tt>char-font</tt> returns the font attribute of the character object;
|
||
|
this will be a non-negative integer less than the (normal) value of
|
||
|
the variable <tt>char-font-limit</tt>.
|
||
|
<br><img align=bottom alt="old_change_end" src="gif/old_change_end.gif">
|
||
|
<P>
|
||
|
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
|
||
|
X3J13 voted in March 1989 (CHARACTER-PROPOSAL) <A NAME=14857> </A>
|
||
|
to eliminate <tt>char-font</tt>.
|
||
|
<P>
|
||
|
<P>The references to the ``normal'' values of the ``variables''
|
||
|
<tt>char-code-limit</tt>,
|
||
|
<tt>char-bits-limit</tt>, and <tt>char-font-limit</tt> in the descriptions
|
||
|
of <tt>char-code</tt>, <tt>char-bits</tt>, and <tt>char-font</tt> were an oversight on
|
||
|
my part. Early in the design of Common Lisp they were indeed variables,
|
||
|
but they are at present defined to be constants, and their values therefore
|
||
|
are always normal and should not change. But this point is now moot.
|
||
|
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
|
||
|
<P>
|
||
|
<BR><b>[Function]</b><BR>
|
||
|
<tt>code-char <i>code</i> &optional (<i>bits</i> 0) (<i>font</i> 0)</tt>
|
||
|
<P>
|
||
|
<img align=bottom alt="old_change_begin" src="gif/old_change_begin.gif"><br>
|
||
|
All three arguments must be non-negative integers.
|
||
|
If it is possible in the implementation to construct a character
|
||
|
object whose code attribute is <i>code</i>, whose bits attribute is <i>bits</i>,
|
||
|
and whose font attribute is <i>font</i>, then such an object is returned;
|
||
|
otherwise <tt>nil</tt> is returned.
|
||
|
<P>
|
||
|
For any integers <i>c</i>, <i>b</i>, and <i>f</i>, if <tt>(code-char <i>c</i> <i>b</i> <i>f</i>)</tt>
|
||
|
is not <tt>nil</tt> then
|
||
|
<P><pre>
|
||
|
(char-code (code-char <i>c</i> <i>b</i> <i>f</i>)) => <i>c</i>
|
||
|
(char-bits (code-char <i>c</i> <i>b</i> <i>f</i>)) => <i>b</i>
|
||
|
(char-font (code-char <i>c</i> <i>b</i> <i>f</i>)) => <i>f</i>
|
||
|
</pre><P>
|
||
|
If the font and bits attributes of a character object <tt>c</tt> are zero,
|
||
|
then it is the case that
|
||
|
<P><pre>
|
||
|
(char= (code-char (char-code c)) c)
|
||
|
</pre><P>
|
||
|
is true.
|
||
|
<br><img align=bottom alt="old_change_end" src="gif/old_change_end.gif">
|
||
|
<P>
|
||
|
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
|
||
|
X3J13 voted in March 1989 (CHARACTER-PROPOSAL) <A NAME=14900> </A>
|
||
|
to eliminate the <i>bits</i> and <i>font</i> arguments from
|
||
|
the specification of <tt>code-char</tt>.
|
||
|
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
|
||
|
<P>
|
||
|
<img align=bottom alt="old_change_begin" src="gif/old_change_begin.gif"><br>
|
||
|
<BR><b>[Function]</b><BR>
|
||
|
<tt>make-char <i>char</i> &optional (<i>bits</i> 0) (<i>font</i> 0)</tt><P>The argument <i>char</i> must be a character,
|
||
|
and <i>bits</i> and <i>font</i> must be non-negative integers.
|
||
|
If it is possible in the implementation to construct a character
|
||
|
object whose code attribute is the same as
|
||
|
the code attribute of <i>char</i>,
|
||
|
whose bits attribute is <i>bits</i>,
|
||
|
and whose font attribute is <i>font</i>, then such an object is returned;
|
||
|
otherwise <tt>nil</tt> is returned.
|
||
|
<P>
|
||
|
If <i>bits</i> and <i>font</i> are zero, then <tt>make-char</tt> cannot fail.
|
||
|
This implies that for every character object one can ``turn off''
|
||
|
its bits and font attributes.
|
||
|
<br><img align=bottom alt="old_change_end" src="gif/old_change_end.gif">
|
||
|
<P>
|
||
|
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
|
||
|
X3J13 voted in March 1989 (CHARACTER-PROPOSAL) <A NAME=14921> </A>
|
||
|
to eliminate <tt>make-char</tt>.
|
||
|
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
|
||
|
<P>
|
||
|
<BR> <HR><A NAME=tex2html3250 HREF="node139.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html3248 HREF="node135.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html3242 HREF="node137.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html3252 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html3253 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
||
|
<B> Next:</B> <A NAME=tex2html3251 HREF="node139.html"> Character Conversions</A>
|
||
|
<B>Up:</B> <A NAME=tex2html3249 HREF="node135.html"> Characters</A>
|
||
|
<B> Previous:</B> <A NAME=tex2html3243 HREF="node137.html"> Predicates on Characters</A>
|
||
|
<HR> <P>
|
||
|
<HR>
|
||
|
<P><ADDRESS>
|
||
|
AI.Repository@cs.cmu.edu
|
||
|
</ADDRESS>
|
||
|
</BODY>
|