My various dotfiles

chap-13.texi 50KB

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