~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to info/chap-13.texi

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
@node Characters, Conses, Numbers (Numbers), Top
 
4
@chapter Characters
 
5
 
 
6
@menu
 
7
* Character Concepts::          
 
8
* Characters Dictionary::       
 
9
@end menu
 
10
 
 
11
@node Character Concepts, Characters Dictionary, Characters, Characters
 
12
@section Character Concepts
 
13
 
 
14
@c including concept-characters
 
15
 
 
16
@menu
 
17
* Introduction to Characters::  
 
18
* Introduction to Scripts and Repertoires::  
 
19
* Character Attributes::        
 
20
* Character Categories::        
 
21
* Identity of Characters::      
 
22
* Ordering of Characters::      
 
23
* Character Names::             
 
24
* Treatment of Newline during Input and Output::  
 
25
* Character Encodings::         
 
26
* Documentation of Implementation-Defined Scripts::  
 
27
@end menu
 
28
 
 
29
@node Introduction to Characters, Introduction to Scripts and Repertoires, Character Concepts, Character Concepts
 
30
@subsection Introduction to Characters
 
31
 
 
32
A @i{character}
 
33
@IGindex{character}
 
34
 is an @i{object} that represents a unitary token 
 
35
(@i{e.g.}, a letter, a special symbol, or a ``control character'')
 
36
in an aggregate quantity of text
 
37
(@i{e.g.}, a @i{string} or a text @i{stream}).
 
38
 
 
39
@r{Common Lisp} allows an implementation to provide support 
 
40
for international language @i{characters} as well
 
41
as @i{characters} used in specialized arenas (@i{e.g.}, mathematics).
 
42
 
 
43
The following figures contain lists of @i{defined names} applicable to 
 
44
@i{characters}.
 
45
 
 
46
Figure 13--1 lists some @i{defined names} relating to 
 
47
@i{character} @i{attributes} and @i{character} @i{predicates}.
 
48
 
 
49
@format
 
50
@group
 
51
@noindent
 
52
@w{  alpha-char-p     char-not-equal     char>            }
 
53
@w{  alphanumericp    char-not-greaterp  char>=           }
 
54
@w{  both-case-p      char-not-lessp     digit-char-p     }
 
55
@w{  char-code-limit  char/=             graphic-char-p   }
 
56
@w{  char-equal       char<              lower-case-p     }
 
57
@w{  char-greaterp    char<=             standard-char-p  }
 
58
@w{  char-lessp       char=              upper-case-p     }
 
59
 
 
60
@noindent
 
61
@w{       Figure 13--1: Character defined names -- 1      }
 
62
 
 
63
@end group
 
64
@end format
 
65
 
 
66
Figure 13--2 lists some @i{character} construction and conversion @i{defined names}.
 
67
 
 
68
@format
 
69
@group
 
70
@noindent
 
71
@w{  char-code      char-name    code-char   }
 
72
@w{  char-downcase  char-upcase  digit-char  }
 
73
@w{  char-int       character    name-char   }
 
74
 
 
75
@noindent
 
76
@w{  Figure 13--2: Character defined names -- 2}
 
77
 
 
78
@end group
 
79
@end format
 
80
 
 
81
@node Introduction to Scripts and Repertoires, Character Attributes, Introduction to Characters, Character Concepts
 
82
@subsection Introduction to Scripts and Repertoires
 
83
 
 
84
@menu
 
85
* Character Scripts::           
 
86
* Character Repertoires::       
 
87
@end menu
 
88
 
 
89
@node Character Scripts, Character Repertoires, Introduction to Scripts and Repertoires, Introduction to Scripts and Repertoires
 
90
@subsubsection Character Scripts
 
91
 
 
92
A @i{script} is one of possibly several sets that form an @i{exhaustive partition}
 
93
of the type @b{character}.
 
94
 
 
95
The number of such sets and boundaries between them is @i{implementation-defined}.
 
96
@r{Common Lisp} does not require these sets to be @i{types}, but an @i{implementation}
 
97
is permitted to define such @i{types} as an extension.  Since no @i{character}
 
98
from one @i{script} can ever be a member of another @i{script}, it is generally
 
99
more useful to speak about @i{character} @i{repertoires}.
 
100
 
 
101
Although
 
102
the term ``@i{script}'' is chosen for 
 
103
definitional 
 
104
compatibility with ISO terminology, no @i{conforming implementation} 
 
105
is required to use any particular @i{scripts} standardized by ISO
 
106
or by any other standards organization.
 
107
 
 
108
Whether and how the @i{script} or @i{scripts} used by any given
 
109
@i{implementation} are named is @i{implementation-dependent}.
 
110
 
 
111
@node Character Repertoires,  , Character Scripts, Introduction to Scripts and Repertoires
 
112
@subsubsection Character Repertoires
 
113
 
 
114
A @i{repertoire}
 
115
@IGindex{repertoire}
 
116
 is a @i{type specifier} for a @i{subtype} of @i{type} @b{character}.
 
117
 
 
118
This term is generally used when describing a collection of @i{characters}
 
119
independent of their coding.
 
120
@i{Characters} in @i{repertoires} are only identified
 
121
    by name,
 
122
    by @i{glyph}, or
 
123
    by character description.
 
124
 
 
125
A @i{repertoire} can contain @i{characters} from several
 
126
@i{scripts}, and a @i{character} can appear in more than
 
127
one @i{repertoire}.
 
128
 
 
129
For some examples of @i{repertoires}, see the coded character standards
 
130
ISO 8859/1, ISO 8859/2, and ISO 6937/2.
 
131
Note, however, that although
 
132
the term ``@i{repertoire}'' is chosen for 
 
133
definitional 
 
134
compatibility with ISO terminology, no @i{conforming implementation} 
 
135
is required to use @i{repertoires} standardized by ISO or any other 
 
136
standards organization.
 
137
 
 
138
@node Character Attributes, Character Categories, Introduction to Scripts and Repertoires, Character Concepts
 
139
@subsection Character Attributes
 
140
 
 
141
@i{Characters} have only one @i{standardized} @i{attribute}:
 
142
a @i{code}.  A @i{character}'s @i{code} is a non-negative @i{integer}.
 
143
This @i{code} is composed from a character @i{script} and a character label
 
144
in an @i{implementation-dependent} way.  See the @i{functions} @b{char-code} and @b{code-char}.
 
145
 
 
146
Additional, @i{implementation-defined} @i{attributes} of @i{characters}
 
147
are also permitted
 
148
so that, for example, 
 
149
two @i{characters} with the same @i{code} may differ 
 
150
in some other, @i{implementation-defined} way.
 
151
 
 
152
For any @i{implementation-defined} @i{attribute}
 
153
there is a distinguished value
 
154
called the @i{null}
 
155
@IGindex{null}
 
156
 value for that @i{attribute}. 
 
157
A @i{character} for which each @i{implementation-defined} @i{attribute}
 
158
has the null value for that @i{attribute} is called a @i{simple} @i{character}.
 
159
If the @i{implementation} has no @i{implementation-defined} @i{attributes},
 
160
then all @i{characters} are @i{simple} @i{characters}.
 
161
 
 
162
@node Character Categories, Identity of Characters, Character Attributes, Character Concepts
 
163
@subsection Character Categories
 
164
 
 
165
There are several (overlapping) categories of @i{characters} that have no formally
 
166
associated @i{type} but that are nevertheless useful to name. 
 
167
They include
 
168
     @i{graphic} @i{characters}, 
 
169
     @i{alphabetic}_1 @i{characters},
 
170
     @i{characters} with @i{case} 
 
171
       (@i{uppercase} and @i{lowercase} @i{characters}),
 
172
     @i{numeric} @i{characters},
 
173
     @i{alphanumeric} @i{characters},
 
174
 and @i{digits} (in a given @i{radix}).
 
175
 
 
176
For each @i{implementation-defined} @i{attribute} of a @i{character},
 
177
the documentation for that @i{implementation} must specify whether 
 
178
@i{characters} that differ only in that @i{attribute} are permitted to differ
 
179
in whether are not they are members of one of the aforementioned categories.
 
180
 
 
181
Note that these terms are defined independently of any special syntax 
 
182
which might have been enabled in the @i{current readtable}.
 
183
 
 
184
@menu
 
185
* Graphic Characters::          
 
186
* Alphabetic Characters::       
 
187
* Characters With Case::        
 
188
* Uppercase Characters::        
 
189
* Lowercase Characters::        
 
190
* Corresponding Characters in the Other Case::  
 
191
* Case of Implementation-Defined Characters::  
 
192
* Numeric Characters::          
 
193
* Alphanumeric Characters::     
 
194
* Digits in a Radix::           
 
195
@end menu
 
196
 
 
197
@node Graphic Characters, Alphabetic Characters, Character Categories, Character Categories
 
198
@subsubsection Graphic Characters
 
199
 
 
200
@i{Characters} that are classified as @i{graphic}
 
201
@IGindex{graphic}
 
202
, or displayable, are each
 
203
associated with a glyph, a visual representation of the @i{character}.
 
204
 
 
205
A @i{graphic} @i{character} is one that has a standard textual 
 
206
representation as a single @i{glyph}, such as @t{A} or @t{*} or @t{=}.
 
207
@i{Space}, which effectively has a blank @i{glyph}, is defined
 
208
to be a @i{graphic}.
 
209
 
 
210
Of the @i{standard characters},
 
211
     @i{newline} is @i{non-graphic} 
 
212
 and all others are @i{graphic}; see @ref{Standard Characters}.
 
213
 
 
214
@i{Characters} that are not @i{graphic} are called @i{non-graphic}
 
215
@IGindex{non-graphic}
 
216
.
 
217
 
 
218
@i{Non-graphic} @i{characters} are sometimes informally called
 
219
    ``formatting characters'' 
 
220
 or ``control characters.''
 
221
 
 
222
@t{#\Backspace},
 
223
@t{#\Tab},
 
224
@t{#\Rubout},
 
225
@t{#\Linefeed}, 
 
226
@t{#\Return}, and
 
227
@t{#\Page},
 
228
if they are supported by the @i{implementation},
 
229
are @i{non-graphic}.
 
230
 
 
231
@node Alphabetic Characters, Characters With Case, Graphic Characters, Character Categories
 
232
@subsubsection Alphabetic Characters
 
233
 
 
234
The @i{alphabetic}_1 @i{characters} are
 
235
a subset of the @i{graphic} @i{characters}.
 
236
Of the @i{standard characters}, only these are the @i{alphabetic}_1 @i{characters}:
 
237
 
 
238
@t{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}
 
239
 
 
240
@t{a b c d e f g h i j k l m n o p q r s t u v w x y z}
 
241
 
 
242
Any @i{implementation-defined} @i{character} that has @i{case} 
 
243
must be @i{alphabetic}_1.
 
244
For each @i{implementation-defined} @i{graphic} @i{character} 
 
245
that has no @i{case},
 
246
it is @i{implementation-defined} whether 
 
247
that @i{character} is @i{alphabetic}_1.
 
248
 
 
249
@node Characters With Case, Uppercase Characters, Alphabetic Characters, Character Categories
 
250
@subsubsection Characters With Case
 
251
 
 
252
The @i{characters} with @i{case} are 
 
253
a subset of the @i{alphabetic}_1 @i{characters}.
 
254
A @i{character} with @i{case} has the property of being either
 
255
@i{uppercase} or @i{lowercase}.
 
256
Every @i{character} with @i{case} is in one-to-one correspondence
 
257
with some other @i{character} with the opposite @i{case}.
 
258
 
 
259
@node Uppercase Characters, Lowercase Characters, Characters With Case, Character Categories
 
260
@subsubsection Uppercase Characters
 
261
 
 
262
An uppercase @i{character} is one that has a corresponding
 
263
@i{lowercase} @i{character} that is @i{different} 
 
264
(and can be obtained using @b{char-downcase}).
 
265
 
 
266
Of the @i{standard characters}, only these are @i{uppercase} @i{characters}:
 
267
 
 
268
@t{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}
 
269
 
 
270
@node Lowercase Characters, Corresponding Characters in the Other Case, Uppercase Characters, Character Categories
 
271
@subsubsection Lowercase Characters
 
272
 
 
273
A lowercase @i{character} is one that has a corresponding 
 
274
@i{uppercase} @i{character} that is @i{different} 
 
275
(and can be obtained using @b{char-upcase}).
 
276
 
 
277
Of the @i{standard characters}, only these are @i{lowercase} @i{characters}:
 
278
 
 
279
@t{a b c d e f g h i j k l m n o p q r s t u v w x y z}
 
280
 
 
281
@node Corresponding Characters in the Other Case, Case of Implementation-Defined Characters, Lowercase Characters, Character Categories
 
282
@subsubsection Corresponding Characters in the Other Case
 
283
 
 
284
The @i{uppercase} @i{standard characters} @t{A} through @t{Z} mentioned above
 
285
respectively correspond to
 
286
the @i{lowercase} @i{standard characters} @t{a} through @t{z} mentioned above.
 
287
For example, the @i{uppercase} @i{character} @t{E} 
 
288
corresponds to the @i{lowercase} @i{character} @t{e}, and vice versa.
 
289
 
 
290
@node Case of Implementation-Defined Characters, Numeric Characters, Corresponding Characters in the Other Case, Character Categories
 
291
@subsubsection Case of Implementation-Defined Characters
 
292
 
 
293
An @i{implementation} may define that other @i{implementation-defined}
 
294
@i{graphic} @i{characters} have @i{case}.  Such definitions must always
 
295
be done in pairs---one @i{uppercase} @i{character} in one-to-one 
 
296
@i{correspondence} with one @i{lowercase} @i{character}.
 
297
 
 
298
@node Numeric Characters, Alphanumeric Characters, Case of Implementation-Defined Characters, Character Categories
 
299
@subsubsection Numeric Characters
 
300
 
 
301
The @i{numeric} @i{characters} are
 
302
a subset of the @i{graphic} @i{characters}.
 
303
Of the @i{standard characters}, only these are @i{numeric} @i{characters}:
 
304
 
 
305
@t{0 1 2 3 4 5 6 7 8 9}
 
306
 
 
307
For each @i{implementation-defined} @i{graphic} @i{character} 
 
308
that has no @i{case}, the @i{implementation} must define whether
 
309
or not it is a @i{numeric} @i{character}.
 
310
 
 
311
@node Alphanumeric Characters, Digits in a Radix, Numeric Characters, Character Categories
 
312
@subsubsection Alphanumeric Characters
 
313
 
 
314
The set of @i{alphanumeric} @i{characters} is the union of 
 
315
    the set of @i{alphabetic}_1 @i{characters} 
 
316
and the set of @i{numeric} @i{characters}.
 
317
 
 
318
@node Digits in a Radix,  , Alphanumeric Characters, Character Categories
 
319
@subsubsection Digits in a Radix
 
320
 
 
321
What qualifies as a @i{digit} depends on the @i{radix} 
 
322
(an @i{integer} between @t{2} and @t{36}, inclusive).
 
323
The potential @i{digits} are:
 
324
 
 
325
@t{0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}
 
326
 
 
327
Their respective weights are @t{0}, @t{1}, @t{2}, ... @t{35}.
 
328
In any given radix n, only the first n potential @i{digits} 
 
329
are considered to be @i{digits}.
 
330
For example,
 
331
the digits in radix @t{2}  are @t{0} and @t{1}, 
 
332
the digits in radix @t{10} are @t{0} through @t{9}, and
 
333
the digits in radix @t{16} are @t{0} through @t{F}.
 
334
 
 
335
@i{Case} is not significant in @i{digits}; 
 
336
for example, in radix @t{16}, both @t{F} and @t{f} 
 
337
are @i{digits} with weight @t{15}.
 
338
 
 
339
@node Identity of Characters, Ordering of Characters, Character Categories, Character Concepts
 
340
@subsection Identity of Characters
 
341
 
 
342
Two @i{characters} that are @b{eql}, @b{char=}, or @b{char-equal} 
 
343
are not necessarily @b{eq}.
 
344
 
 
345
@node Ordering of Characters, Character Names, Identity of Characters, Character Concepts
 
346
@subsection Ordering of Characters
 
347
 
 
348
The total ordering on @i{characters} is guaranteed to have 
 
349
the following properties: 
 
350
 
 
351
@table @asis
 
352
 
 
353
@item @t{*}  
 
354
If two @i{characters} have the same @i{implementation-defined} @i{attributes},
 
355
then their ordering by @b{char<} is consistent with the numerical
 
356
ordering by the predicate @b{<} on their code @i{attributes}.
 
357
 
 
358
@item @t{*}  
 
359
If two @i{characters} differ in any @i{attribute}, then they
 
360
are not @b{char=}.
 
361
 
 
362
[Reviewer Note by Barmar: I wonder if we should say that the ordering may be dependent on the
 
363
                  @i{implementation-defined} @i{attributes}.]
 
364
 
 
365
@item @t{*}  
 
366
The total ordering is not necessarily the same as the total ordering
 
367
  on the @i{integers} produced by applying @b{char-int} to the
 
368
  @i{characters}.
 
369
 
 
370
@item @t{*}  
 
371
While @i{alphabetic}_1 @i{standard characters} of a given @i{case}
 
372
  must    
 
373
  obey a partial ordering,
 
374
  they need not be contiguous; it is permissible for 
 
375
  @i{uppercase} and @i{lowercase} @i{characters} to be interleaved. 
 
376
  Thus @t{(char<= #\a x #\z)} 
 
377
  is not a valid way of determining whether or not @t{x} is a
 
378
  @i{lowercase} @i{character}.  
 
379
 
 
380
@end table
 
381
 
 
382
Of the @i{standard characters}, 
 
383
those which are @i{alphanumeric} obey the following partial ordering:
 
384
 
 
385
@example
 
386
 A<B<C<D<E<F<G<H<I<J<K<L<M<N<O<P<Q<R<S<T<U<V<W<X<Y<Z
 
387
 a<b<c<d<e<f<g<h<i<j<k<l<m<n<o<p<q<r<s<t<u<v<w<x<y<z
 
388
 0<1<2<3<4<5<6<7<8<9
 
389
 either 9<A or Z<0
 
390
 either 9<a or z<0                                                      
 
391
@end example
 
392
 
 
393
This implies that, for @i{standard characters}, @i{alphabetic}_1 
 
394
ordering holds within each @i{case} (@i{uppercase} and @i{lowercase}), 
 
395
and that the @i{numeric} @i{characters} as a group are not interleaved
 
396
with @i{alphabetic} @i{characters}.
 
397
However, the ordering or possible interleaving of @i{uppercase} @i{characters}
 
398
and @i{lowercase} @i{characters} is @i{implementation-defined}.
 
399
 
 
400
@node Character Names, Treatment of Newline during Input and Output, Ordering of Characters, Character Concepts
 
401
@subsection Character Names
 
402
 
 
403
The following @i{character} @i{names} must be present in all 
 
404
@i{conforming implementations}:
 
405
 
 
406
@table @asis
 
407
 
 
408
@item @t{Newline}  
 
409
The character that represents the division between lines.
 
410
An implementation must translate between @t{#\Newline}, 
 
411
a single-character representation, and whatever external representation(s)
 
412
may be used.
 
413
 
 
414
@item @t{Space}  
 
415
The space or blank character.
 
416
@end table
 
417
 
 
418
The following names are @i{semi-standard}; 
 
419
if an @i{implementation} supports them,
 
420
they should be used for the described @i{characters} and no others.
 
421
 
 
422
@table @asis
 
423
 
 
424
@item @t{Rubout}  
 
425
The rubout or delete character.
 
426
 
 
427
@item @t{Page}  
 
428
The form-feed or page-separator character.
 
429
 
 
430
@item @t{Tab}  
 
431
The tabulate character.
 
432
 
 
433
@item @t{Backspace}  
 
434
The backspace character.
 
435
 
 
436
@item @t{Return}  
 
437
The carriage return character.
 
438
 
 
439
@item @t{Linefeed}  
 
440
The line-feed character.
 
441
@end table
 
442
 
 
443
In some @i{implementations},
 
444
one or more of these @i{character} @i{names} 
 
445
might denote a @i{standard character}; 
 
446
for example,
 
447
@t{#\Linefeed} and @t{#\Newline} might be the @i{same} @i{character}
 
448
in some @i{implementations}.
 
449
 
 
450
@node Treatment of Newline during Input and Output, Character Encodings, Character Names, Character Concepts
 
451
@subsection Treatment of Newline during Input and Output
 
452
 
 
453
When the character @t{#\Newline} is written to an output file,
 
454
the implementation must take the appropriate action
 
455
to produce a line division.  This might involve writing out a
 
456
record or translating @t{#\Newline} to a CR/LF sequence.
 
457
When reading, a corresponding reverse transformation must take place.
 
458
 
 
459
@node Character Encodings, Documentation of Implementation-Defined Scripts, Treatment of Newline during Input and Output, Character Concepts
 
460
@subsection Character Encodings
 
461
 
 
462
A @i{character} is sometimes represented merely by its @i{code}, and sometimes
 
463
by another @i{integer} value which is composed from the @i{code} and all 
 
464
@i{implementation-defined} @i{attributes}
 
465
(in an @i{implementation-defined} way
 
466
that might vary between @i{Lisp images} even in the same @i{implementation}).
 
467
This @i{integer}, returned by the function @b{char-int}, is called the
 
468
character's ``encoding.''
 
469
There is no corresponding function
 
470
from a character's encoding back to the @i{character}, 
 
471
since its primary intended uses include things like hashing where an inverse operation
 
472
is not really called for.
 
473
 
 
474
@node Documentation of Implementation-Defined Scripts,  , Character Encodings, Character Concepts
 
475
@subsection Documentation of Implementation-Defined Scripts
 
476
 
 
477
   An @i{implementation} must document the @i{character} @i{scripts} 
 
478
   it supports. For each @i{character} @i{script} supported,
 
479
   the documentation must describe at least the following:
 
480
@table @asis
 
481
 
 
482
@item @t{*}  
 
483
Character labels, glyphs, and descriptions.
 
484
   Character labels must be uniquely named using only Latin capital letters A--Z,
 
485
   hyphen (-), and digits 0--9.
 
486
@item @t{*}  
 
487
Reader canonicalization.
 
488
   Any mechanisms by which @b{read} treats
 
489
   @i{different} characters as equivalent must be documented.
 
490
@item @t{*}  
 
491
The impact on @b{char-upcase},
 
492
                 @b{char-downcase},
 
493
             and the case-sensitive @i{format directives}.
 
494
   In particular, for each @i{character} with @i{case},
 
495
   whether it is @i{uppercase} or @i{lowercase},
 
496
   and which @i{character} is its equivalent in the opposite case.
 
497
@item @t{*}  
 
498
The behavior of the case-insensitive @i{functions}
 
499
     @b{char-equal}, @b{char-not-equal},
 
500
     @b{char-lessp}, @b{char-greaterp}, 
 
501
     @b{char-not-greaterp}, and @b{char-not-lessp}.
 
502
@item @t{*}  
 
503
The behavior of any @i{character} @i{predicates};
 
504
   in particular, the effects of
 
505
   @b{alpha-char-p},
 
506
   @b{lower-case-p},
 
507
   @b{upper-case-p},
 
508
   @b{both-case-p},
 
509
   @b{graphic-char-p}, 
 
510
   and
 
511
   @b{alphanumericp}.
 
512
@item @t{*}  
 
513
The interaction with file I/O, in particular,
 
514
   the supported coded character sets (for example, ISO8859/1-1987)
 
515
   and external encoding schemes supported are documented.
 
516
@end table
 
517
 
 
518
@c end of including concept-characters
 
519
 
 
520
@node Characters Dictionary,  , Character Concepts, Characters
 
521
@section Characters Dictionary
 
522
 
 
523
@c including dict-characters
 
524
 
 
525
@menu
 
526
* character (System Class)::    
 
527
* base-char::                   
 
528
* standard-char::               
 
529
* extended-char::               
 
530
* char=::                       
 
531
* character::                   
 
532
* characterp::                  
 
533
* alpha-char-p::                
 
534
* alphanumericp::               
 
535
* digit-char::                  
 
536
* digit-char-p::                
 
537
* graphic-char-p::              
 
538
* standard-char-p::             
 
539
* char-upcase::                 
 
540
* upper-case-p::                
 
541
* char-code::                   
 
542
* char-int::                    
 
543
* code-char::                   
 
544
* char-code-limit::             
 
545
* char-name::                   
 
546
* name-char::                   
 
547
@end menu
 
548
 
 
549
@node character (System Class), base-char, Characters Dictionary, Characters Dictionary
 
550
@subsection character                                                    [System Class]
 
551
 
 
552
@subsubheading  Class Precedence List::
 
553
@b{character},
 
554
@b{t}
 
555
 
 
556
@subsubheading  Description::
 
557
 
 
558
A @i{character} is an @i{object} that 
 
559
represents a unitary token in an aggregate quantity of text;
 
560
see @ref{Character Concepts}.
 
561
 
 
562
The @i{types} @b{base-char} and @b{extended-char}
 
563
form an @i{exhaustive partition} of the @i{type} @b{character}.
 
564
 
 
565
@subsubheading  See Also::
 
566
 
 
567
@ref{Character Concepts},
 
568
@ref{Sharpsign Backslash},
 
569
@ref{Printing Characters}
 
570
 
 
571
@node base-char, standard-char, character (System Class), Characters Dictionary
 
572
@subsection base-char                                                            [Type]
 
573
 
 
574
@subsubheading  Supertypes::
 
575
 
 
576
@b{base-char},
 
577
@b{character},
 
578
@b{t}
 
579
 
 
580
@subsubheading  Description::
 
581
 
 
582
The @i{type} @b{base-char} is defined as the @i{upgraded array element type} 
 
583
of @b{standard-char}.
 
584
An @i{implementation} can support additional @i{subtypes} of @i{type} @b{character}
 
585
(besides the ones listed in this standard) 
 
586
that might or might not be @i{supertypes} of @i{type} @b{base-char}.
 
587
In addition, an @i{implementation} can define @b{base-char}
 
588
to be the @i{same} @i{type} as @b{character}.
 
589
 
 
590
@i{Base characters} are distinguished in the following respects:
 
591
@table @asis
 
592
 
 
593
@item 1.  
 
594
The @i{type} @b{standard-char} is a @i{subrepertoire} of the @i{type} @b{base-char}.
 
595
@item 2.  
 
596
The selection of @i{base characters} that are not @i{standard characters}
 
597
              is implementation defined.
 
598
@item 3.  
 
599
Only @i{objects} of the @i{type} @b{base-char} can be 
 
600
             @i{elements} of a @i{base string}.
 
601
@item 4.  
 
602
No upper bound is specified for the number of characters in the 
 
603
@b{base-char} @i{repertoire}; the size of that @i{repertoire}
 
604
is 
 
605
@i{implementation-defined}.
 
606
The lower bound is~96, the number of @i{standard characters}.
 
607
@end table
 
608
 
 
609
Whether a character is a @i{base character} depends on the way 
 
610
that an @i{implementation} represents @i{strings}, 
 
611
and not any other properties of the @i{implementation} or the host operating system.  
 
612
For example, one implementation might encode all @i{strings} 
 
613
as characters having 16-bit encodings, and another might have
 
614
two kinds of @i{strings}: those with characters having 8-bit 
 
615
encodings and those with characters having 16-bit encodings.  In the
 
616
first @i{implementation}, the @i{type} @b{base-char} is equivalent to
 
617
the @i{type} @b{character}: there is only one kind of @i{string}.
 
618
In the second @i{implementation}, the @i{base characters} might be 
 
619
those @i{characters} that could be stored in a @i{string} of @i{characters}
 
620
having 8-bit encodings.  In such an implementation,
 
621
the @i{type} @b{base-char} is a @i{proper subtype} of the @i{type} @b{character}.
 
622
 
 
623
The @i{type} @b{standard-char} is a 
 
624
 
 
625
@i{subtype} of @i{type} @b{base-char}.
 
626
 
 
627
@node standard-char, extended-char, base-char, Characters Dictionary
 
628
@subsection standard-char                                                        [Type]
 
629
 
 
630
@subsubheading  Supertypes::
 
631
 
 
632
@b{standard-char},
 
633
 
 
634
@b{base-char},
 
635
 
 
636
@b{character},
 
637
@b{t}
 
638
 
 
639
@subsubheading  Description::
 
640
 
 
641
A fixed set of 96 @i{characters} required to be present in all 
 
642
@i{conforming implementations}.  @i{Standard characters} are 
 
643
defined in @ref{Standard Characters}.
 
644
 
 
645
Any @i{character} that is not @i{simple} is not a @i{standard character}.
 
646
 
 
647
@subsubheading  See Also::
 
648
 
 
649
@ref{Standard Characters}
 
650
 
 
651
@node extended-char, char=, standard-char, Characters Dictionary
 
652
@subsection extended-char                                                        [Type]
 
653
 
 
654
@subsubheading  Supertypes::
 
655
 
 
656
@b{extended-char},
 
657
@b{character},
 
658
@b{t}
 
659
 
 
660
@subsubheading  Description::
 
661
 
 
662
The @i{type} @b{extended-char} is equivalent to the @i{type} @t{(and character (not base-char))}.
 
663
 
 
664
@subsubheading  Notes::
 
665
 
 
666
The @i{type} @b{extended-char} might 
 
667
have no @i{elements}_4
 
668
in @i{implementations} in which all @i{characters} are of @i{type} @b{base-char}.
 
669
 
 
670
@node char=, character, extended-char, Characters Dictionary
 
671
@subsection char=, char/=, char<, char>, char<=, char>=, 
 
672
@subheading char-equal, char-not-equal, char-lessp, char-greaterp, char-not-greaterp,
 
673
@subheading char-not-lessp
 
674
@flushright
 
675
@i{[Function]}
 
676
@end flushright
 
677
 
 
678
@code{@r{char=}}  @i{@r{&rest} characters^+} @result{}  @i{generalized-boolean}
 
679
 
 
680
@code{@r{char/=}}  @i{@r{&rest} characters^+} @result{}  @i{generalized-boolean}
 
681
 
 
682
@code{@r{char<}}  @i{@r{&rest} characters^+} @result{}  @i{generalized-boolean}
 
683
 
 
684
@code{@r{char>}}  @i{@r{&rest} characters^+} @result{}  @i{generalized-boolean}
 
685
 
 
686
@code{@r{char<=}}  @i{@r{&rest} characters^+} @result{}  @i{generalized-boolean}
 
687
 
 
688
@code{@r{char>=}}  @i{@r{&rest} characters^+} @result{}  @i{generalized-boolean}
 
689
 
 
690
@code{char-equal}  @i{@r{&rest} characters^+} @result{}  @i{generalized-boolean}
 
691
 
 
692
@code{char-not-equal}  @i{@r{&rest} characters^+} @result{}  @i{generalized-boolean}
 
693
 
 
694
@code{char-lessp}  @i{@r{&rest} characters^+} @result{}  @i{generalized-boolean}
 
695
 
 
696
@code{char-greaterp}  @i{@r{&rest} characters^+} @result{}  @i{generalized-boolean}
 
697
 
 
698
@code{char-not-greaterp}  @i{@r{&rest} characters^+} @result{}  @i{generalized-boolean}
 
699
 
 
700
@code{char-not-lessp}  @i{@r{&rest} characters^+} @result{}  @i{generalized-boolean}
 
701
 
 
702
@subsubheading  Arguments and Values::
 
703
 
 
704
@i{character}---a @i{character}.
 
705
 
 
706
@i{generalized-boolean}---a @i{generalized boolean}.
 
707
 
 
708
@subsubheading  Description::
 
709
 
 
710
These predicates compare @i{characters}.
 
711
 
 
712
@b{char=} returns @i{true} if all @i{characters} are the @i{same};
 
713
otherwise, it returns @i{false}.
 
714
 
 
715
If two @i{characters} differ 
 
716
in any @i{implementation-defined} @i{attributes},
 
717
then they are not @b{char=}.
 
718
 
 
719
@b{char/=} returns @i{true} if all @i{characters} are different;
 
720
otherwise, it returns @i{false}.
 
721
 
 
722
@b{char<} returns @i{true} if the @i{characters} are monotonically increasing; 
 
723
otherwise, it returns @i{false}.
 
724
 
 
725
If two @i{characters} 
 
726
have @i{identical} @i{implementation-defined} @i{attributes}, 
 
727
then their ordering by @b{char<} is 
 
728
consistent with the numerical ordering by the predicate @t{<} on their @i{codes}.
 
729
 
 
730
@b{char>} returns @i{true} if the @i{characters} are monotonically decreasing; 
 
731
otherwise, it returns @i{false}.
 
732
 
 
733
If two @i{characters} have 
 
734
@i{identical} @i{implementation-defined} @i{attributes},
 
735
then their ordering by @b{char>} is 
 
736
consistent with the numerical ordering by the predicate @t{>} on their @i{codes}. 
 
737
 
 
738
@b{char<=} returns @i{true} 
 
739
if the @i{characters} are monotonically nondecreasing; 
 
740
otherwise, it returns @i{false}.
 
741
 
 
742
If two @i{characters} have
 
743
@i{identical} @i{implementation-defined} @i{attributes},
 
744
then their ordering by @b{char<=} is
 
745
consistent with the numerical ordering by the predicate @t{<=} on their @i{codes}. 
 
746
 
 
747
@b{char>=} returns @i{true} 
 
748
if the @i{characters} are monotonically nonincreasing; 
 
749
otherwise, it returns @i{false}.
 
750
 
 
751
If two @i{characters} have
 
752
@i{identical} @i{implementation-defined} @i{attributes},
 
753
then their ordering by @b{char>=} is 
 
754
consistent with the numerical ordering by the predicate @t{>=} on their @i{codes}. 
 
755
 
 
756
    @b{char-equal},
 
757
    @b{char-not-equal},
 
758
    @b{char-lessp},
 
759
    @b{char-greaterp},
 
760
    @b{char-not-greaterp},
 
761
and @b{char-not-lessp}
 
762
are similar to 
 
763
    @b{char=},
 
764
    @b{char/=},
 
765
    @b{char<},
 
766
    @b{char>},
 
767
    @b{char<=},
 
768
    @b{char>=},
 
769
respectively,
 
770
except that they ignore differences in @i{case} and
 
771
 
 
772
might have an @i{implementation-defined} behavior 
 
773
for @i{non-simple} @i{characters}.
 
774
For example, an @i{implementation} might define that 
 
775
@b{char-equal}, @i{etc.} ignore certain 
 
776
@i{implementation-defined} @i{attributes}.
 
777
The effect, if any, 
 
778
of each @i{implementation-defined} @i{attribute}
 
779
upon these functions must be specified as part of the definition of that @i{attribute}.
 
780
 
 
781
@subsubheading  Examples::
 
782
 
 
783
@example
 
784
 (char= #\d #\d) @result{}  @i{true}
 
785
 (char= #\A #\a) @result{}  @i{false}
 
786
 (char= #\d #\x) @result{}  @i{false}
 
787
 (char= #\d #\D) @result{}  @i{false}
 
788
 (char/= #\d #\d) @result{}  @i{false}
 
789
 (char/= #\d #\x) @result{}  @i{true}
 
790
 (char/= #\d #\D) @result{}  @i{true}
 
791
 (char= #\d #\d #\d #\d) @result{}  @i{true}
 
792
 (char/= #\d #\d #\d #\d) @result{}  @i{false}
 
793
 (char= #\d #\d #\x #\d) @result{}  @i{false}
 
794
 (char/= #\d #\d #\x #\d) @result{}  @i{false}
 
795
 (char= #\d #\y #\x #\c) @result{}  @i{false}
 
796
 (char/= #\d #\y #\x #\c) @result{}  @i{true}
 
797
 (char= #\d #\c #\d) @result{}  @i{false}
 
798
 (char/= #\d #\c #\d) @result{}  @i{false}
 
799
 (char< #\d #\x) @result{}  @i{true}
 
800
 (char<= #\d #\x) @result{}  @i{true}
 
801
 (char< #\d #\d) @result{}  @i{false}
 
802
 (char<= #\d #\d) @result{}  @i{true}
 
803
 (char< #\a #\e #\y #\z) @result{}  @i{true}
 
804
 (char<= #\a #\e #\y #\z) @result{}  @i{true}
 
805
 (char< #\a #\e #\e #\y) @result{}  @i{false}
 
806
 (char<= #\a #\e #\e #\y) @result{}  @i{true}
 
807
 (char> #\e #\d) @result{}  @i{true}
 
808
 (char>= #\e #\d) @result{}  @i{true}
 
809
 (char> #\d #\c #\b #\a) @result{}  @i{true}
 
810
 (char>= #\d #\c #\b #\a) @result{}  @i{true}
 
811
 (char> #\d #\d #\c #\a) @result{}  @i{false}
 
812
 (char>= #\d #\d #\c #\a) @result{}  @i{true}
 
813
 (char> #\e #\d #\b #\c #\a) @result{}  @i{false}
 
814
 (char>= #\e #\d #\b #\c #\a) @result{}  @i{false}
 
815
 (char> #\z #\A) @result{}  @i{implementation-dependent}
 
816
 (char> #\Z #\a) @result{}  @i{implementation-dependent}
 
817
 (char-equal #\A #\a) @result{}  @i{true}
 
818
 (stable-sort (list #\b #\A #\B #\a #\c #\C) #'char-lessp)
 
819
@result{}  (#\A #\a #\b #\B #\c #\C)
 
820
 (stable-sort (list #\b #\A #\B #\a #\c #\C) #'char<)
 
821
@result{}  (#\A #\B #\C #\a #\b #\c) ;Implementation A
 
822
@result{}  (#\a #\b #\c #\A #\B #\C) ;Implementation B
 
823
@result{}  (#\a #\A #\b #\B #\c #\C) ;Implementation C
 
824
@result{}  (#\A #\a #\B #\b #\C #\c) ;Implementation D
 
825
@result{}  (#\A #\B #\a #\b #\C #\c) ;Implementation E
 
826
@end example
 
827
 
 
828
@subsubheading  Exceptional Situations::
 
829
 
 
830
Should signal an error of @i{type} @b{program-error} 
 
831
                       if at least one @i{character} is not supplied.
 
832
 
 
833
@subsubheading  See Also::
 
834
 
 
835
@ref{Character Syntax},
 
836
@ref{Documentation of Implementation-Defined Scripts}
 
837
 
 
838
@subsubheading  Notes::
 
839
 
 
840
If characters differ in their @i{code} @i{attribute} 
 
841
or any @i{implementation-defined} @i{attribute},
 
842
they are considered to be different by @b{char=}.
 
843
 
 
844
There is no requirement that @t{(eq c1 c2)} be true merely because
 
845
@t{(char= c1 c2)} is @i{true}.  While @b{eq} can distinguish two 
 
846
@i{characters}
 
847
that @b{char=} does not, it is distinguishing them not
 
848
as @i{characters}, but in some sense on the basis of a lower level
 
849
implementation characteristic.
 
850
If @t{(eq c1 c2)} is @i{true},
 
851
then @t{(char= c1 c2)} is also true.
 
852
@b{eql} and @b{equal}
 
853
compare @i{characters} in the same
 
854
way that @b{char=} does.
 
855
 
 
856
The manner in which @i{case} is used by 
 
857
     @b{char-equal},
 
858
     @b{char-not-equal},
 
859
     @b{char-lessp},
 
860
     @b{char-greaterp},
 
861
     @b{char-not-greaterp},
 
862
 and @b{char-not-lessp}
 
863
implies an ordering for @i{standard characters} such that
 
864
@t{A=a}, @t{B=b}, and so on, up to @t{Z=z}, and furthermore either
 
865
@t{9<A} or @t{Z<0}.
 
866
 
 
867
@node character, characterp, char=, Characters Dictionary
 
868
@subsection character                                                        [Function]
 
869
 
 
870
@code{character}  @i{character} @result{}  @i{denoted-character}
 
871
 
 
872
@subsubheading  Arguments and Values:: 
 
873
 
 
874
@i{character}---a @i{character designator}.
 
875
 
 
876
@i{denoted-character}---a @i{character}.
 
877
 
 
878
@subsubheading  Description::
 
879
 
 
880
Returns the @i{character} denoted by the @i{character} @i{designator}.
 
881
 
 
882
@subsubheading  Examples::
 
883
 
 
884
@example
 
885
 (character #\a) @result{}  #\a
 
886
 (character "a") @result{}  #\a
 
887
 (character 'a) @result{}  #\A
 
888
 (character '\a) @result{}  #\a
 
889
 (character 65.) is an error.
 
890
 (character 'apple) is an error.
 
891
@end example
 
892
 
 
893
@subsubheading  Exceptional Situations::
 
894
 
 
895
Should signal an error of @i{type} @b{type-error}
 
896
                              if @i{object} is not a @i{character designator}.
 
897
 
 
898
@subsubheading  See Also::
 
899
 
 
900
@ref{coerce}
 
901
 
 
902
@subsubheading  Notes::
 
903
 
 
904
@example
 
905
 (character @i{object}) @equiv{} (coerce @i{object} 'character)
 
906
@end example
 
907
 
 
908
@node characterp, alpha-char-p, character, Characters Dictionary
 
909
@subsection characterp                                                       [Function]
 
910
 
 
911
@code{characterp}  @i{object} @result{}  @i{generalized-boolean}
 
912
 
 
913
@subsubheading  Arguments and Values::
 
914
 
 
915
@i{object}---an @i{object}.
 
916
 
 
917
@i{generalized-boolean}---a @i{generalized boolean}.
 
918
 
 
919
@subsubheading  Description::
 
920
 
 
921
Returns @i{true} if @i{object} is of @i{type} @b{character};
 
922
otherwise, returns @i{false}.
 
923
 
 
924
@subsubheading  Examples::                  
 
925
 
 
926
@example
 
927
 (characterp #\a) @result{}  @i{true}
 
928
 (characterp 'a) @result{}  @i{false}
 
929
 (characterp "a") @result{}  @i{false}
 
930
 (characterp 65.) @result{}  @i{false}
 
931
 (characterp #\Newline) @result{}  @i{true}
 
932
 ;; This next example presupposes an implementation 
 
933
 ;; in which #\Rubout is an implementation-defined character.
 
934
 (characterp #\Rubout) @result{}  @i{true}
 
935
@end example
 
936
 
 
937
@subsubheading  See Also::
 
938
 
 
939
@ref{character}
 
940
 (@i{type} and @i{function}), 
 
941
@ref{typep}
 
942
 
 
943
@subsubheading  Notes::
 
944
 
 
945
@example
 
946
 (characterp @i{object}) @equiv{} (typep @i{object} 'character)
 
947
@end example
 
948
 
 
949
@node alpha-char-p, alphanumericp, characterp, Characters Dictionary
 
950
@subsection alpha-char-p                                                     [Function]
 
951
 
 
952
@code{alpha-char-p}  @i{character} @result{}  @i{generalized-boolean}
 
953
 
 
954
@subsubheading  Arguments and Values::
 
955
 
 
956
@i{character}---a @i{character}.
 
957
 
 
958
@i{generalized-boolean}---a @i{generalized boolean}.
 
959
 
 
960
@subsubheading  Description::
 
961
 
 
962
Returns @i{true} if @i{character} is an @i{alphabetic}_1 @i{character};
 
963
otherwise, returns @i{false}.
 
964
 
 
965
@subsubheading  Examples::
 
966
 
 
967
@example
 
968
 (alpha-char-p #\a) @result{}  @i{true}
 
969
 (alpha-char-p #\5) @result{}  @i{false}
 
970
 (alpha-char-p #\Newline) @result{}  @i{false}
 
971
 ;; This next example presupposes an implementation
 
972
 ;; in which #\\alpha is a defined character.
 
973
 (alpha-char-p #\\alpha) @result{}  @i{implementation-dependent}
 
974
@end example
 
975
 
 
976
@subsubheading  Affected By::
 
977
 
 
978
None.
 
979
(In particular, the results of this predicate are independent 
 
980
of any special syntax which might have been enabled in the @i{current readtable}.)
 
981
 
 
982
@subsubheading  Exceptional Situations::
 
983
 
 
984
Should signal an error of @i{type} @b{type-error}
 
985
                              if @i{character} is not a @i{character}.
 
986
 
 
987
@subsubheading  See Also::
 
988
 
 
989
@ref{alphanumericp}
 
990
,
 
991
@ref{Documentation of Implementation-Defined Scripts}
 
992
 
 
993
@node alphanumericp, digit-char, alpha-char-p, Characters Dictionary
 
994
@subsection alphanumericp                                                    [Function]
 
995
 
 
996
@code{alphanumericp}  @i{character} @result{}  @i{generalized-boolean}
 
997
 
 
998
@subsubheading  Arguments and Values:: 
 
999
 
 
1000
@i{character}---a @i{character}.
 
1001
 
 
1002
@i{generalized-boolean}---a @i{generalized boolean}.
 
1003
 
 
1004
@subsubheading  Description::
 
1005
 
 
1006
Returns @i{true} if @i{character} is an @i{alphabetic}_1 @i{character} 
 
1007
                   or a  @i{numeric}    @i{character};
 
1008
otherwise, returns @i{false}.
 
1009
 
 
1010
@subsubheading  Examples::
 
1011
 
 
1012
@example
 
1013
 (alphanumericp #\Z) @result{}  @i{true}
 
1014
 (alphanumericp #\9) @result{}  @i{true}
 
1015
 (alphanumericp #\Newline) @result{}  @i{false}
 
1016
 (alphanumericp #\#) @result{}  @i{false}
 
1017
@end example
 
1018
 
 
1019
@subsubheading  Affected By::
 
1020
 
 
1021
None.
 
1022
(In particular, the results of this predicate are independent 
 
1023
of any special syntax which might have been enabled in the @i{current readtable}.)
 
1024
 
 
1025
@subsubheading  Exceptional Situations::
 
1026
 
 
1027
Should signal an error of @i{type} @b{type-error}
 
1028
                              if @i{character} is not a @i{character}.
 
1029
 
 
1030
@subsubheading  See Also::
 
1031
 
 
1032
@ref{alpha-char-p}
 
1033
 
1034
@ref{graphic-char-p}
 
1035
 
1036
@ref{digit-char-p}
 
1037
 
 
1038
@subsubheading  Notes::
 
1039
 
 
1040
Alphanumeric characters are graphic
 
1041
as defined by @b{graphic-char-p}.
 
1042
The alphanumeric characters are a subset of the graphic characters.
 
1043
The standard characters @t{A} through @t{Z},
 
1044
                        @t{a} through @t{z},
 
1045
                    and @t{0} through @t{9} are alphanumeric characters.
 
1046
 
 
1047
@example
 
1048
 (alphanumericp x)
 
1049
   @equiv{} (or (alpha-char-p x) (not (null (digit-char-p x))))
 
1050
@end example
 
1051
 
 
1052
@node digit-char, digit-char-p, alphanumericp, Characters Dictionary
 
1053
@subsection digit-char                                                       [Function]
 
1054
 
 
1055
@code{digit-char}  @i{weight @r{&optional} radix} @result{}  @i{char}
 
1056
 
 
1057
@subsubheading  Arguments and Values::
 
1058
 
 
1059
@i{weight}---a non-negative @i{integer}.
 
1060
 
 
1061
@i{radix}---a @i{radix}.
 
1062
 The default is @t{10}.
 
1063
 
 
1064
@i{char}---a @i{character} or @i{false}.
 
1065
 
 
1066
@subsubheading  Description::   
 
1067
 
 
1068
If @i{weight} is less than @i{radix},
 
1069
@b{digit-char} returns a @i{character} which has that @i{weight}
 
1070
when considered as a digit in the specified radix.
 
1071
If the resulting @i{character} is to be an @i{alphabetic}_1 @i{character},
 
1072
it will be an uppercase @i{character}.
 
1073
 
 
1074
If @i{weight} is greater than or equal to @i{radix},
 
1075
@b{digit-char} returns @i{false}.
 
1076
 
 
1077
@subsubheading  Examples::
 
1078
 
 
1079
@example
 
1080
 (digit-char 0) @result{}  #\0
 
1081
 (digit-char 10 11) @result{}  #\A
 
1082
 (digit-char 10 10) @result{}  @i{false}
 
1083
 (digit-char 7) @result{}  #\7
 
1084
 (digit-char 12) @result{}  @i{false}
 
1085
 (digit-char 12 16) @result{}  #\C  ;not #\c
 
1086
 (digit-char 6 2) @result{}  @i{false}
 
1087
 (digit-char 1 2) @result{}  #\1
 
1088
@end example
 
1089
 
 
1090
@subsubheading  See Also::
 
1091
 
 
1092
@ref{digit-char-p}
 
1093
,
 
1094
@ref{graphic-char-p}
 
1095
,
 
1096
@ref{Character Syntax}
 
1097
 
 
1098
@subsubheading  Notes::
 
1099
 
 
1100
@node digit-char-p, graphic-char-p, digit-char, Characters Dictionary
 
1101
@subsection digit-char-p                                                     [Function]
 
1102
 
 
1103
@code{digit-char-p}  @i{char @r{&optional} radix} @result{}  @i{weight}
 
1104
 
 
1105
@subsubheading  Arguments and Values::
 
1106
 
 
1107
@i{char}---a @i{character}.
 
1108
 
 
1109
@i{radix}---a @i{radix}.
 
1110
 The default is @t{10}.
 
1111
 
 
1112
@i{weight}---either a non-negative @i{integer} less than @i{radix}, 
 
1113
                 or @i{false}.
 
1114
 
 
1115
@subsubheading  Description::
 
1116
 
 
1117
Tests whether @i{char} is a digit in the specified @i{radix}
 
1118
(@i{i.e.}, with a weight less than @i{radix}).
 
1119
If it is a digit in that @i{radix},
 
1120
its weight is returned as an @i{integer}; 
 
1121
otherwise @b{nil} is returned.
 
1122
 
 
1123
@subsubheading  Examples::
 
1124
 
 
1125
@example
 
1126
 (digit-char-p #\5)    @result{}  5
 
1127
 (digit-char-p #\5 2)  @result{}  @i{false}
 
1128
 (digit-char-p #\A)    @result{}  @i{false}
 
1129
 (digit-char-p #\a)    @result{}  @i{false}
 
1130
 (digit-char-p #\A 11) @result{}  10
 
1131
 (digit-char-p #\a 11) @result{}  10
 
1132
 (mapcar #'(lambda (radix) 
 
1133
             (map 'list #'(lambda (x) (digit-char-p x radix)) 
 
1134
                  "059AaFGZ"))
 
1135
         '(2 8 10 16 36))
 
1136
 @result{}  ((0 NIL NIL NIL NIL NIL NIL NIL)
 
1137
     (0 5 NIL NIL NIL NIL NIL NIL)
 
1138
     (0 5 9 NIL NIL NIL NIL NIL)
 
1139
     (0 5 9 10 10 15 NIL NIL)
 
1140
     (0 5 9 10 10 15 16 35))
 
1141
@end example
 
1142
 
 
1143
@subsubheading  Affected By::
 
1144
 
 
1145
None.
 
1146
(In particular, the results of this predicate are independent 
 
1147
of any special syntax which might have been enabled in the @i{current readtable}.)
 
1148
 
 
1149
@subsubheading  See Also::
 
1150
 
 
1151
@ref{alphanumericp}
 
1152
 
 
1153
@subsubheading  Notes::
 
1154
 
 
1155
Digits are @i{graphic} @i{characters}.
 
1156
 
 
1157
@node graphic-char-p, standard-char-p, digit-char-p, Characters Dictionary
 
1158
@subsection graphic-char-p                                                   [Function]
 
1159
 
 
1160
@code{graphic-char-p}  @i{char} @result{}  @i{generalized-boolean}
 
1161
 
 
1162
@subsubheading  Arguments and Values::
 
1163
 
 
1164
@i{char}---a @i{character}.
 
1165
 
 
1166
@i{generalized-boolean}---a @i{generalized boolean}.
 
1167
 
 
1168
@subsubheading  Description::
 
1169
 
 
1170
Returns @i{true} if @i{character} is a @i{graphic} @i{character};
 
1171
otherwise, returns @i{false}.
 
1172
 
 
1173
@subsubheading  Examples::                   
 
1174
 
 
1175
@example
 
1176
 (graphic-char-p #\G) @result{}  @i{true}
 
1177
 (graphic-char-p #\#) @result{}  @i{true}
 
1178
 (graphic-char-p #\Space) @result{}  @i{true}
 
1179
 (graphic-char-p #\Newline) @result{}  @i{false}
 
1180
@end example
 
1181
 
 
1182
@subsubheading  Exceptional Situations::
 
1183
 
 
1184
Should signal an error of @i{type} @b{type-error}
 
1185
                              if @i{character} is not a @i{character}.
 
1186
 
 
1187
@subsubheading  See Also::
 
1188
 
 
1189
@ref{read}
 
1190
,
 
1191
@ref{Character Syntax},
 
1192
@ref{Documentation of Implementation-Defined Scripts}
 
1193
 
 
1194
@node standard-char-p, char-upcase, graphic-char-p, Characters Dictionary
 
1195
@subsection standard-char-p                                                  [Function]
 
1196
 
 
1197
@code{standard-char-p}  @i{character} @result{}  @i{generalized-boolean}
 
1198
 
 
1199
@subsubheading  Arguments and Values::
 
1200
 
 
1201
@i{character}---a @i{character}.
 
1202
 
 
1203
@i{generalized-boolean}---a @i{generalized boolean}.
 
1204
 
 
1205
@subsubheading  Description::
 
1206
 
 
1207
Returns @i{true} if @i{character} is of @i{type} @b{standard-char};
 
1208
otherwise, returns @i{false}.
 
1209
 
 
1210
@subsubheading  Examples::                
 
1211
 
 
1212
@example
 
1213
 (standard-char-p #\Space) @result{}  @i{true}
 
1214
 (standard-char-p #\~) @result{}  @i{true}
 
1215
 ;; This next example presupposes an implementation
 
1216
 ;; in which #\Bell is a defined character.
 
1217
 (standard-char-p #\Bell) @result{}  @i{false}
 
1218
@end example
 
1219
 
 
1220
@subsubheading  Exceptional Situations::
 
1221
 
 
1222
Should signal an error of @i{type} @b{type-error}
 
1223
                              if @i{character} is not a @i{character}.
 
1224
 
 
1225
@node char-upcase, upper-case-p, standard-char-p, Characters Dictionary
 
1226
@subsection char-upcase, char-downcase                                       [Function]
 
1227
 
 
1228
@code{char-upcase}  @i{character} @result{}  @i{corresponding-character}
 
1229
 
 
1230
@code{char-downcase}  @i{character} @result{}  @i{corresponding-character}
 
1231
 
 
1232
@subsubheading  Arguments and Values:: 
 
1233
 
 
1234
@i{character}, @i{corresponding-character}---a @i{character}.
 
1235
 
 
1236
@subsubheading  Description::
 
1237
 
 
1238
If @i{character} is a @i{lowercase} @i{character},
 
1239
@b{char-upcase} returns the corresponding @i{uppercase} @i{character}.
 
1240
Otherwise, @b{char-upcase} just returns the given @i{character}.
 
1241
 
 
1242
If @i{character} is an @i{uppercase} @i{character},
 
1243
@b{char-downcase} returns the corresponding @i{lowercase} @i{character}.
 
1244
Otherwise, @b{char-downcase} just returns the given @i{character}.
 
1245
 
 
1246
The result only ever differs from @i{character} 
 
1247
in its @i{code} @i{attribute};
 
1248
all @i{implementation-defined} @i{attributes} are preserved.
 
1249
 
 
1250
@subsubheading  Examples::
 
1251
 
 
1252
@example
 
1253
 (char-upcase #\a) @result{}  #\A
 
1254
 (char-upcase #\A) @result{}  #\A
 
1255
 (char-downcase #\a) @result{}  #\a
 
1256
 (char-downcase #\A) @result{}  #\a
 
1257
 (char-upcase #\9) @result{}  #\9
 
1258
 (char-downcase #\9) @result{}  #\9
 
1259
 (char-upcase #\@@) @result{}  #\@@
 
1260
 (char-downcase #\@@) @result{}  #\@@
 
1261
 ;; Note that this next example might run for a very long time in 
 
1262
 ;; some implementations if CHAR-CODE-LIMIT happens to be very large
 
1263
 ;; for that implementation.
 
1264
 (dotimes (code char-code-limit)
 
1265
   (let ((char (code-char code)))
 
1266
     (when char
 
1267
       (unless (cond ((upper-case-p char) (char= (char-upcase (char-downcase char)) char))
 
1268
                     ((lower-case-p char) (char= (char-downcase (char-upcase char)) char))
 
1269
                     (t (and (char= (char-upcase (char-downcase char)) char)
 
1270
                             (char= (char-downcase (char-upcase char)) char))))
 
1271
         (return char)))))
 
1272
@result{}  NIL
 
1273
@end example
 
1274
 
 
1275
@subsubheading  Exceptional Situations::
 
1276
 
 
1277
Should signal an error of @i{type} @b{type-error}
 
1278
                              if @i{character} is not a @i{character}.
 
1279
 
 
1280
@subsubheading  See Also::
 
1281
 
 
1282
@ref{upper-case-p}
 
1283
,
 
1284
@ref{alpha-char-p}
 
1285
,
 
1286
@ref{Characters With Case},
 
1287
@ref{Documentation of Implementation-Defined Scripts}
 
1288
 
 
1289
@subsubheading  Notes::
 
1290
 
 
1291
If the @i{corresponding-char} is @i{different} than @i{character},
 
1292
then both the @i{character} and the @i{corresponding-char} have @i{case}.
 
1293
 
 
1294
Since @b{char-equal} ignores the @i{case} of the @i{characters} it compares,
 
1295
the @i{corresponding-character} is always the @i{same} as @i{character}
 
1296
under @b{char-equal}.
 
1297
 
 
1298
@node upper-case-p, char-code, char-upcase, Characters Dictionary
 
1299
@subsection upper-case-p, lower-case-p, both-case-p                          [Function]
 
1300
 
 
1301
@code{upper-case-p}  @i{character} @result{}  @i{generalized-boolean}
 
1302
 
 
1303
@code{lower-case-p}  @i{character} @result{}  @i{generalized-boolean}
 
1304
 
 
1305
@code{both-case-p}  @i{character} @result{}  @i{generalized-boolean}
 
1306
 
 
1307
@subsubheading  Arguments and Values::
 
1308
 
 
1309
@i{character}---a @i{character}.
 
1310
 
 
1311
@i{generalized-boolean}---a @i{generalized boolean}.
 
1312
 
 
1313
@subsubheading  Description::
 
1314
 
 
1315
These functions test the case of a given @i{character}.
 
1316
 
 
1317
@b{upper-case-p} returns @i{true} if @i{character} is an @i{uppercase} @i{character};
 
1318
otherwise, returns @i{false}.
 
1319
 
 
1320
@b{lower-case-p} returns @i{true} if @i{character} is a @i{lowercase} @i{character};
 
1321
otherwise, returns @i{false}.
 
1322
 
 
1323
@b{both-case-p} returns @i{true} if @i{character} is a @i{character} with @i{case};
 
1324
otherwise, returns @i{false}.
 
1325
 
 
1326
@subsubheading  Examples::
 
1327
 
 
1328
@example
 
1329
 (upper-case-p #\A) @result{}  @i{true}
 
1330
 (upper-case-p #\a) @result{}  @i{false}
 
1331
 (both-case-p #\a) @result{}  @i{true}
 
1332
 (both-case-p #\5) @result{}  @i{false}
 
1333
 (lower-case-p #\5) @result{}  @i{false}
 
1334
 (upper-case-p #\5) @result{}  @i{false}
 
1335
 ;; This next example presupposes an implementation 
 
1336
 ;; in which #\Bell is an implementation-defined character.
 
1337
 (lower-case-p #\Bell) @result{}  @i{false}
 
1338
@end example
 
1339
 
 
1340
@subsubheading  Exceptional Situations::
 
1341
 
 
1342
Should signal an error of @i{type} @b{type-error}
 
1343
                              if @i{character} is not a @i{character}.
 
1344
 
 
1345
@subsubheading  See Also::
 
1346
 
 
1347
@ref{char-upcase}
 
1348
,
 
1349
@b{char-downcase},
 
1350
@ref{Characters With Case},
 
1351
@ref{Documentation of Implementation-Defined Scripts}
 
1352
 
 
1353
@node char-code, char-int, upper-case-p, Characters Dictionary
 
1354
@subsection char-code                                                        [Function]
 
1355
 
 
1356
@code{char-code}  @i{character} @result{}  @i{code}
 
1357
 
 
1358
@subsubheading  Arguments and Values:: 
 
1359
 
 
1360
@i{character}---a @i{character}.
 
1361
 
 
1362
@i{code}---a @i{character code}.
 
1363
 
 
1364
@subsubheading  Description::
 
1365
 
 
1366
@b{char-code} returns the @i{code} @i{attribute} of @i{character}.
 
1367
 
 
1368
@subsubheading  Examples::
 
1369
 
 
1370
@example
 
1371
;; An implementation using ASCII character encoding 
 
1372
;; might return these values:
 
1373
(char-code #\$) @result{}  36
 
1374
(char-code #\a) @result{}  97
 
1375
@end example
 
1376
 
 
1377
@subsubheading  Exceptional Situations::
 
1378
 
 
1379
Should signal an error of @i{type} @b{type-error}
 
1380
                              if @i{character} is not a @i{character}.
 
1381
 
 
1382
@subsubheading  See Also::
 
1383
 
 
1384
@ref{char-code-limit}
 
1385
 
 
1386
@node char-int, code-char, char-code, Characters Dictionary
 
1387
@subsection char-int                                                         [Function]
 
1388
 
 
1389
@code{char-int}  @i{character} @result{}  @i{integer}
 
1390
 
 
1391
@subsubheading  Arguments and Values:: 
 
1392
 
 
1393
@i{character}---a @i{character}.
 
1394
 
 
1395
@i{integer}---a non-negative @i{integer}.
 
1396
 
 
1397
@subsubheading  Description::
 
1398
 
 
1399
Returns a non-negative @i{integer} encoding the @i{character} object.
 
1400
The manner in which the @i{integer} is computed is @i{implementation-dependent}.
 
1401
In contrast to @b{sxhash}, the result is not guaranteed to be independent 
 
1402
of the particular @i{Lisp image}.
 
1403
 
 
1404
If @i{character} has no @i{implementation-defined} @i{attributes},
 
1405
the results of @b{char-int} and @b{char-code} are the same. 
 
1406
 
 
1407
@example
 
1408
 (char= @i{c1} @i{c2}) @equiv{} (= (char-int @i{c1}) (char-int @i{c2}))
 
1409
@end example
 
1410
 
 
1411
for characters @i{c1} and @i{c2}.
 
1412
 
 
1413
@subsubheading  Examples::
 
1414
 
 
1415
@example
 
1416
 (char-int #\A) @result{}  65       ; implementation A
 
1417
 (char-int #\A) @result{}  577      ; implementation B
 
1418
 (char-int #\A) @result{}  262145   ; implementation C
 
1419
@end example
 
1420
 
 
1421
@subsubheading  See Also::
 
1422
 
 
1423
@ref{char-code}
 
1424
 
 
1425
@node code-char, char-code-limit, char-int, Characters Dictionary
 
1426
@subsection code-char                                                        [Function]
 
1427
 
 
1428
@code{code-char}  @i{code} @result{}  @i{char-p}
 
1429
 
 
1430
@subsubheading  Arguments and Values::
 
1431
 
 
1432
@i{code}---a @i{character code}.
 
1433
 
 
1434
@i{char-p}---a @i{character} or @b{nil}.
 
1435
 
 
1436
@subsubheading  Description::
 
1437
 
 
1438
Returns a @i{character} with the @i{code} @i{attribute} given by @i{code}.
 
1439
If no such @i{character} exists and one cannot be created, @b{nil} is returned.
 
1440
 
 
1441
@subsubheading  Examples::
 
1442
 
 
1443
@example
 
1444
(code-char 65.) @result{}  #\A  ;in an implementation using ASCII codes
 
1445
(code-char (char-code #\Space)) @result{}  #\Space  ;in any implementation
 
1446
@end example
 
1447
 
 
1448
@subsubheading  Affected By::
 
1449
 
 
1450
The @i{implementation}'s character encoding.
 
1451
 
 
1452
@subsubheading  See Also::
 
1453
 
 
1454
@ref{char-code}
 
1455
 
 
1456
@subsubheading  Notes::
 
1457
 
 
1458
@node char-code-limit, char-name, code-char, Characters Dictionary
 
1459
@subsection char-code-limit                                         [Constant Variable]
 
1460
 
 
1461
@subsubheading  Constant Value::
 
1462
 
 
1463
A non-negative @i{integer}, the exact magnitude of which
 
1464
is @i{implementation-dependent}, but which is not less
 
1465
than @t{96} (the number of @i{standard characters}).
 
1466
 
 
1467
@subsubheading  Description::
 
1468
 
 
1469
The upper exclusive bound on the @i{value} returned by 
 
1470
the @i{function} @b{char-code}.
 
1471
 
 
1472
@subsubheading  See Also::
 
1473
 
 
1474
@ref{char-code}
 
1475
 
 
1476
@subsubheading  Notes::
 
1477
 
 
1478
The @i{value} of @b{char-code-limit} might be larger than the actual
 
1479
number of @i{characters} supported by the @i{implementation}.
 
1480
 
 
1481
@node char-name, name-char, char-code-limit, Characters Dictionary
 
1482
@subsection char-name                                                        [Function]
 
1483
 
 
1484
@code{char-name}  @i{character} @result{}  @i{name}
 
1485
 
 
1486
@subsubheading  Arguments and Values::
 
1487
 
 
1488
@i{character}---a @i{character}.
 
1489
 
 
1490
@i{name}---a @i{string} or @b{nil}.
 
1491
 
 
1492
@subsubheading  Description::
 
1493
 
 
1494
Returns a @i{string} that is the @i{name} of the @i{character},
 
1495
or @b{nil} if the @i{character} has no @i{name}.
 
1496
 
 
1497
All @i{non-graphic} characters are required to have @i{names}
 
1498
unless they have some @i{implementation-defined} @i{attribute}
 
1499
which is not @i{null}.  Whether or not other @i{characters}
 
1500
have @i{names} is @i{implementation-dependent}.
 
1501
 
 
1502
The @i{standard characters}
 
1503
<@i{Newline}> and <@i{Space}> have the respective names @t{"Newline"} and @t{"Space"}.
 
1504
The @i{semi-standard} @i{characters}
 
1505
<@i{Tab}>, <@i{Page}>, <@i{Rubout}>, <@i{Linefeed}>, <@i{Return}>, and <@i{Backspace}> 
 
1506
(if they are supported by the @i{implementation})
 
1507
have the respective names
 
1508
@t{"Tab"},  @t{"Page"},  @t{"Rubout"},  @t{"Linefeed"},  @t{"Return"}, and @t{"Backspace"}
 
1509
(in the indicated case, even though name lookup by ``@t{#\}'' 
 
1510
and by the @i{function} @b{name-char} is not case sensitive).
 
1511
 
 
1512
@subsubheading  Examples::
 
1513
 
 
1514
@example
 
1515
 (char-name #\ ) @result{}  "Space"
 
1516
 (char-name #\Space) @result{}  "Space"
 
1517
 (char-name #\Page) @result{}  "Page"
 
1518
 
 
1519
 (char-name #\a)
 
1520
@result{}  NIL
 
1521
@i{OR}@result{} "LOWERCASE-a"
 
1522
@i{OR}@result{} "Small-A"
 
1523
@i{OR}@result{} "LA01"
 
1524
 
 
1525
 (char-name #\A)
 
1526
@result{}  NIL
 
1527
@i{OR}@result{} "UPPERCASE-A"
 
1528
@i{OR}@result{} "Capital-A"
 
1529
@i{OR}@result{} "LA02"
 
1530
 
 
1531
 ;; Even though its CHAR-NAME can vary, #\A prints as #\A
 
1532
 (prin1-to-string (read-from-string (format nil "#\\~A" (or (char-name #\A) "A"))))
 
1533
@result{}  "#\\A"
 
1534
@end example
 
1535
 
 
1536
@subsubheading  Exceptional Situations::
 
1537
 
 
1538
Should signal an error of @i{type} @b{type-error}
 
1539
                              if @i{character} is not a @i{character}.
 
1540
 
 
1541
@subsubheading  See Also::
 
1542
 
 
1543
@ref{name-char}
 
1544
,
 
1545
@ref{Printing Characters}
 
1546
 
 
1547
@subsubheading  Notes::
 
1548
 
 
1549
@i{Non-graphic} 
 
1550
@i{characters} having @i{names} are written by the @i{Lisp printer}
 
1551
as ``@t{#\}'' followed by the their @i{name}; see @ref{Printing Characters}.
 
1552
 
 
1553
@node name-char,  , char-name, Characters Dictionary
 
1554
@subsection name-char                                                        [Function]
 
1555
 
 
1556
@code{name-char}  @i{name} @result{}  @i{char-p}
 
1557
 
 
1558
@subsubheading  Arguments and Values::
 
1559
 
 
1560
@i{name}---a @i{string designator}.
 
1561
 
 
1562
@i{char-p}---a @i{character} or @b{nil}.
 
1563
 
 
1564
@subsubheading  Description::
 
1565
 
 
1566
Returns the @i{character} @i{object} whose @i{name} is
 
1567
@i{name} (as determined by @b{string-equal}---@i{i.e.}, lookup is not case sensitive).
 
1568
If such a @i{character} does not exist, @b{nil} is returned.
 
1569
 
 
1570
@subsubheading  Examples::
 
1571
 
 
1572
@example
 
1573
(name-char 'space) @result{}  #\Space
 
1574
(name-char "space") @result{}  #\Space
 
1575
(name-char "Space") @result{}  #\Space
 
1576
(let ((x (char-name #\a)))
 
1577
  (or (not x) (eql (name-char x) #\a))) @result{}  @i{true}
 
1578
@end example
 
1579
 
 
1580
@subsubheading  Exceptional Situations::
 
1581
 
 
1582
Should signal an error of @i{type} @b{type-error}
 
1583
                              if @i{name} is not a @i{string designator}.
 
1584
 
 
1585
@subsubheading  See Also::
 
1586
 
 
1587
@ref{char-name}
 
1588
 
 
1589
@c end of including dict-characters
 
1590
 
 
1591
@c %**end of chapter
 
1592