dict-characters.tex 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314
  1. % -*- Mode: TeX -*-
  2. % Character Comparison
  3. % Character Types
  4. % Character Roles
  5. % Character Casification
  6. % Character Codes
  7. % Character Names
  8. %-------------------- Character Types --------------------
  9. %%% ========== CHARACTER (System Class)
  10. \begincom{character}\ftype{System Class}
  11. \label Class Precedence List::
  12. \typeref{character},
  13. \typeref{t}
  14. \label Description::
  15. A \term{character} is an \term{object} that
  16. represents a unitary token in an aggregate quantity of text;
  17. \seesection\CharacterConcepts.
  18. \issue{CHARACTER-VS-CHAR:LESS-INCONSISTENT-SHORT}
  19. \issue{CHARACTER-PROPOSAL:2-3-1}
  20. \Thetypes{base-char} and \typeref{extended-char}
  21. form an \term{exhaustive partition} of \thetype{character}.
  22. \endissue{CHARACTER-PROPOSAL:2-3-1}
  23. \endissue{CHARACTER-VS-CHAR:LESS-INCONSISTENT-SHORT}
  24. \label See Also::
  25. {\secref\CharacterConcepts},
  26. {\secref\SharpsignBackslash},
  27. {\secref\PrintingCharacters}
  28. \endcom%{character}\ftype{System Class}
  29. \begincom{base-char}\ftype{Type}
  30. \issue{CHARACTER-VS-CHAR:LESS-INCONSISTENT-SHORT}
  31. \label Supertypes::
  32. \typeref{base-char},
  33. \typeref{character},
  34. \typeref{t}
  35. \label Description::
  36. \Thetype{base-char} is defined as the \term{upgraded array element type}
  37. of \typeref{standard-char}.
  38. An \term{implementation} can support additional \subtypesof{character}
  39. (besides the ones listed in this standard)
  40. that might or might not be \supertypesof{base-char}.
  41. In addition, an \term{implementation} can define \typeref{base-char}
  42. to be the \term{same} \term{type} as \typeref{character}.
  43. \term{Base characters} are distinguished in the following respects:
  44. \beginlist
  45. \itemitem{1.} \Thetype{standard-char} is a \term{subrepertoire} of \thetype{base-char}.
  46. \itemitem{2.} The selection of \term{base characters} that are not \term{standard characters}
  47. is implementation defined.
  48. \itemitem{3.} Only \term{objects} of \thetype{base-char} can be
  49. \term{elements} of a \term{base string}.
  50. \itemitem{4.}
  51. No upper bound is specified for the number of characters in the
  52. \typeref{base-char} \term{repertoire}; the size of that \term{repertoire}
  53. is %\term{implementation-dependent}
  54. \term{implementation-defined}.
  55. The lower bound is~96, the number of \term{standard characters}.
  56. %defined for \clisp.
  57. \endlist
  58. %The distinction of base characters is largely a pragmatic
  59. %choice. It permits efficient handling of common situations, may
  60. %be privileged for host system I/O, and can serve as an
  61. %intermediate basis for portability, less general than the standard
  62. %characters, but possibly more useful across a narrower range of
  63. %implementations.
  64. %
  65. %Many computers have some "base" character representation which
  66. %is a function of hardware instructions for dealing with characters,
  67. %as well as the organization of the file system. The base character
  68. %representation is likely to be the smallest transaction unit permitted
  69. %for text file and terminal I/O operations. On a system with a record
  70. %based I/O paradigm, the base character representation is likely to
  71. %be the smallest record quantum. On many computer systems,
  72. %this representation is a byte.
  73. Whether a character is a \term{base character} depends on the way
  74. that an \term{implementation} represents \term{strings},
  75. and not any other properties of the \term{implementation} or the host operating system.
  76. For example, one implementation might encode all \term{strings}
  77. as characters having 16-bit encodings, and another might have
  78. two kinds of \term{strings}: those with characters having 8-bit
  79. encodings and those with characters having 16-bit encodings. In the
  80. first \term{implementation}, \thetype{base-char} is equivalent to
  81. \thetype{character}: there is only one kind of \term{string}.
  82. In the second \term{implementation}, the \term{base characters} might be
  83. those \term{characters} that could be stored in a \term{string} of \term{characters}
  84. having 8-bit encodings. In such an implementation,
  85. \thetype{base-char} is a \term{proper subtype} of \thetype{character}.
  86. %KMP: Note that I think there could be implementations in which the 8-bit strings
  87. %are -not- base characters, if all the standard-chars were not
  88. %representable using the 8-bit encoding scheme. In such a case,
  89. %it might be that (upgraded-array-element-type 'standard-char) returned
  90. %the 16-bit representation. It might be that the 8-bit representation
  91. %was something else entirely.
  92. %% 2.15.0 15
  93. \Thetype{standard-char} is a
  94. \issue{CHARACTER-PROPOSAL:2-3-1}
  95. \subtypeof{base-char}.
  96. %This text will be deleted:
  97. %subtype of \typeref{character}.
  98. \endissue{CHARACTER-PROPOSAL:2-3-1}
  99. %\thetype{string-char} is a \subtypeof{character}.
  100. \endissue{CHARACTER-VS-CHAR:LESS-INCONSISTENT-SHORT}
  101. \endcom%{base-char}\ftype{Type}
  102. \begincom{standard-char}\ftype{Type}
  103. \issue{STANDARD-REPERTOIRE-GRATUITOUS:RENAME}
  104. \label Supertypes::
  105. \typeref{standard-char},
  106. \issue{CHARACTER-VS-CHAR:LESS-INCONSISTENT-SHORT}
  107. \typeref{base-char},
  108. \endissue{CHARACTER-VS-CHAR:LESS-INCONSISTENT-SHORT}
  109. \typeref{character},
  110. \typeref{t}
  111. \label Description::
  112. A fixed set of 96 \term{characters} required to be present in all
  113. \term{conforming implementations}. \term{Standard characters} are
  114. defined in \secref\StandardChars.
  115. %%% 13.2.0 4
  116. \issue{CHARACTER-PROPOSAL:2-1-1}
  117. Any \term{character} that is not \term{simple} is not a \term{standard character}.
  118. \endissue{CHARACTER-PROPOSAL:2-1-1}
  119. \endissue{STANDARD-REPERTOIRE-GRATUITOUS:RENAME}
  120. \label See Also::
  121. {\secref\StandardChars}
  122. \endcom%{standard-char}\ftype{Type}
  123. \begincom{extended-char}\ftype{Type}
  124. \issue{CHARACTER-PROPOSAL:2-3-1}
  125. \issue{CHARACTER-VS-CHAR:LESS-INCONSISTENT-SHORT}
  126. \label Supertypes::
  127. \typeref{extended-char},
  128. \typeref{character},
  129. \typeref{t}
  130. \label Description::
  131. \Thetype{extended-char} is equivalent to the \term{type} \f{(and character (not base-char))}.
  132. %% 2.3.0 1
  133. %% 2.3.0 2
  134. \label Notes::
  135. %This next paragraph as added per Barrett's suggestion:
  136. \Thetype{extended-char} might
  137. %be equivalent to \thetype{nil}
  138. %% Replaced as controversial. -kmp 4-Feb-92
  139. have no \term{elements}\meaning{4}
  140. in \term{implementations} in which all \term{characters} are \oftype{base-char}.
  141. \endissue{CHARACTER-VS-CHAR:LESS-INCONSISTENT-SHORT}
  142. \endissue{CHARACTER-PROPOSAL:2-3-1}
  143. \endcom%{extended-char}\ftype{Type}
  144. %-------------------- Character Comparison --------------------
  145. %%% ========== CHAR-EQUAL
  146. %%% ========== CHAR-NOT-EQUAL
  147. %%% ========== CHAR-LESSP
  148. %%% ========== CHAR-GREATERP
  149. %%% ========== CHAR-NOT-LESSP
  150. %%% ========== CHAR-NOT-GREATERP
  151. %%% ========== CHAR=
  152. %%% ========== CHAR/=
  153. %%% ========== CHAR<
  154. %%% ========== CHAR>
  155. %%% ========== CHAR>=
  156. %%% ========== CHAR<=
  157. \begincom{char=, char/=, char<, char>, char<=, char>=,
  158. char-equal, char-not-equal, char-lessp, char-greaterp, char-not-greaterp,
  159. char-not-lessp}\ftype{Function}
  160. \label Syntax::
  161. \DefunMultiWithValues {{\rest} \plus{characters}}
  162. {generalized-boolean}
  163. {\entry{{char$=$}}
  164. \entry{{char$/=$}}
  165. \entry{{char$<$}}
  166. \entry{{char$>$}}
  167. \entry{{char$<=$}}
  168. \entry{{char$>=$}}
  169. \noalign{\vskip 5pt}
  170. \entry{char-equal}
  171. \entry{char-not-equal}
  172. \entry{char-lessp}
  173. \entry{char-greaterp}
  174. \entry{char-not-greaterp}
  175. \entry{char-not-lessp}}
  176. \label Arguments and Values::
  177. \param{character}---a \term{character}.
  178. \param{generalized-boolean}---a \term{generalized boolean}.
  179. \label Description::
  180. These predicates compare \term{characters}.
  181. \funref{char=} returns \term{true} if all \param{characters} are the \term{same};
  182. otherwise, it returns \term{false}.
  183. \issue{CHARACTER-PROPOSAL:2-1-1}
  184. If two \param{characters} differ
  185. in any \term{implementation-defined} \term{attributes},
  186. then they are not \funref{char=}.
  187. \endissue{CHARACTER-PROPOSAL:2-1-1}
  188. \funref{char/=} returns \term{true} if all \param{characters} are different;
  189. otherwise, it returns \term{false}.
  190. \funref{char<} returns \term{true} if the \param{characters} are monotonically increasing;
  191. otherwise, it returns \term{false}.
  192. \issue{CHARACTER-PROPOSAL:2-1-1}
  193. If two \term{characters}
  194. have \term{identical} \term{implementation-defined} \term{attributes},
  195. then their ordering by \funref{char<} is
  196. consistent with the numerical ordering by the predicate \f{<} on their \term{codes}.
  197. \endissue{CHARACTER-PROPOSAL:2-1-1}
  198. \funref{char>} returns \term{true} if the \param{characters} are monotonically decreasing;
  199. otherwise, it returns \term{false}.
  200. \issue{CHARACTER-PROPOSAL:2-1-1}
  201. If two \term{characters} have
  202. \term{identical} \term{implementation-defined} \term{attributes},
  203. then their ordering by \funref{char>} is
  204. consistent with the numerical ordering by the predicate \f{>} on their \term{codes}.
  205. \endissue{CHARACTER-PROPOSAL:2-1-1}
  206. \funref{char<=} returns \term{true}
  207. if the \param{characters} are monotonically nondecreasing;
  208. otherwise, it returns \term{false}.
  209. \issue{CHARACTER-PROPOSAL:2-1-1}
  210. If two \term{characters} have
  211. \term{identical} \term{implementation-defined} \term{attributes},
  212. then their ordering by \funref{char<=} is
  213. consistent with the numerical ordering by the predicate \f{<=} on their \term{codes}.
  214. \endissue{CHARACTER-PROPOSAL:2-1-1}
  215. \funref{char>=} returns \term{true}
  216. if the \param{characters} are monotonically nonincreasing;
  217. otherwise, it returns \term{false}.
  218. \issue{CHARACTER-PROPOSAL:2-1-1}
  219. If two \term{characters} have
  220. \term{identical} \term{implementation-defined} \term{attributes},
  221. then their ordering by \funref{char>=} is
  222. consistent with the numerical ordering by the predicate \f{>=} on their \term{codes}.
  223. \endissue{CHARACTER-PROPOSAL:2-1-1}
  224. \funref{char-equal},
  225. \funref{char-not-equal},
  226. \funref{char-lessp},
  227. \funref{char-greaterp},
  228. \funref{char-not-greaterp},
  229. and \funref{char-not-lessp}
  230. are similar to
  231. \funref{char=},
  232. \funref{char/=},
  233. \funref{char<},
  234. \funref{char>},
  235. \funref{char<=},
  236. \funref{char>=},
  237. respectively,
  238. except that they ignore differences in \term{case} and
  239. \issue{CHARACTER-PROPOSAL:2-1-1}
  240. % that the effect, if any, of each \term{implementation-defined} \term{attribute}
  241. % must be specified as part of the definition of that \term{attribute}.
  242. %% Sandra thought the above was awkward. Trying again. -kmp 26-Jan-92
  243. might have an \term{implementation-defined} behavior
  244. for \term{non-simple} \term{characters}.
  245. % For example, an implementation might define that certain
  246. % \term{implementation-defined} \term{attributes} are ignored by
  247. % \funref{char-equal}, \i{etc.}
  248. %% More rewording to soothe awkwardness. -kmp 26-Jan-92
  249. For example, an \term{implementation} might define that
  250. \funref{char-equal}, \i{etc.} ignore certain
  251. \term{implementation-defined} \term{attributes}.
  252. The effect, if any,
  253. of each \term{implementation-defined} \term{attribute}
  254. upon these functions must be specified as part of the definition of that \term{attribute}.
  255. %% This part has been moved to the notes.
  256. % %% 13.2.0 char-equal
  257. % This means that for the \term{standard characters}, the ordering used by
  258. % \funref{char-equal}, \etc. is such that
  259. % \f{A=a}, \f{B=b}, and so on, up to \f{Z=z}, and furthermore either
  260. % \f{9<A} or \f{Z<0}.
  261. \endissue{CHARACTER-PROPOSAL:2-1-1}
  262. %% 13.2.0 31
  263. \label Examples::
  264. \issue{CHARACTER-PROPOSAL:2-1-1}
  265. \code
  266. (char= #\\d #\\d) \EV \term{true}
  267. (char= #\\A #\\a) \EV \term{false}
  268. (char= #\\d #\\x) \EV \term{false}
  269. (char= #\\d #\\D) \EV \term{false}
  270. (char/= #\\d #\\d) \EV \term{false}
  271. (char/= #\\d #\\x) \EV \term{true}
  272. (char/= #\\d #\\D) \EV \term{true}
  273. (char= #\\d #\\d #\\d #\\d) \EV \term{true}
  274. (char/= #\\d #\\d #\\d #\\d) \EV \term{false}
  275. (char= #\\d #\\d #\\x #\\d) \EV \term{false}
  276. (char/= #\\d #\\d #\\x #\\d) \EV \term{false}
  277. (char= #\\d #\\y #\\x #\\c) \EV \term{false}
  278. (char/= #\\d #\\y #\\x #\\c) \EV \term{true}
  279. (char= #\\d #\\c #\\d) \EV \term{false}
  280. (char/= #\\d #\\c #\\d) \EV \term{false}
  281. (char< #\\d #\\x) \EV \term{true}
  282. (char<= #\\d #\\x) \EV \term{true}
  283. (char< #\\d #\\d) \EV \term{false}
  284. (char<= #\\d #\\d) \EV \term{true}
  285. (char< #\\a #\\e #\\y #\\z) \EV \term{true}
  286. (char<= #\\a #\\e #\\y #\\z) \EV \term{true}
  287. (char< #\\a #\\e #\\e #\\y) \EV \term{false}
  288. (char<= #\\a #\\e #\\e #\\y) \EV \term{true}
  289. (char> #\\e #\\d) \EV \term{true}
  290. (char>= #\\e #\\d) \EV \term{true}
  291. (char> #\\d #\\c #\\b #\\a) \EV \term{true}
  292. (char>= #\\d #\\c #\\b #\\a) \EV \term{true}
  293. (char> #\\d #\\d #\\c #\\a) \EV \term{false}
  294. (char>= #\\d #\\d #\\c #\\a) \EV \term{true}
  295. (char> #\\e #\\d #\\b #\\c #\\a) \EV \term{false}
  296. (char>= #\\e #\\d #\\b #\\c #\\a) \EV \term{false}
  297. (char> #\\z #\\A) \EV \term{implementation-dependent}
  298. (char> #\\Z #\\a) \EV \term{implementation-dependent}
  299. (char-equal #\\A #\\a) \EV \term{true}
  300. (stable-sort (list #\\b #\\A #\\B #\\a #\\c #\\C) #'char-lessp)
  301. \EV (#\\A #\\a #\\b #\\B #\\c #\\C)
  302. (stable-sort (list #\\b #\\A #\\B #\\a #\\c #\\C) #'char<)
  303. \EV (#\\A #\\B #\\C #\\a #\\b #\\c) ;Implementation A
  304. \EV (#\\a #\\b #\\c #\\A #\\B #\\C) ;Implementation B
  305. \EV (#\\a #\\A #\\b #\\B #\\c #\\C) ;Implementation C
  306. \EV (#\\A #\\a #\\B #\\b #\\C #\\c) ;Implementation D
  307. \EV (#\\A #\\B #\\a #\\b #\\C #\\c) ;Implementation E
  308. \endcode
  309. %GLS observes that there are 15 other possibilities here:
  310. % (#\\A #\\a #\\b #\\c #\\B #\\C)
  311. % (#\\A #\\B #\\a #\\b #\\c #\\C)
  312. % (#\\a #\\A #\\b #\\B #\\C #\\c)
  313. % (#\\a #\\A #\\B #\\b #\\C #\\c)
  314. % (#\\a #\\A #\\b #\\c #\\B #\\C)
  315. % (#\\a #\\A #\\B #\\b #\\c #\\C)
  316. % (#\\a #\\A #\\B #\\C #\\b #\\c)
  317. % (#\\A #\\a #\\B #\\b #\\c #\\C)
  318. % (#\\A #\\a #\\B #\\C #\\b #\\c)
  319. % (#\\A #\\B #\\a #\\C #\\b #\\c)
  320. % (#\\a #\\b #\\A #\\c #\\B #\\C)
  321. % (#\\a #\\b #\\A #\\B #\\c #\\C)
  322. % (#\\a #\\b #\\A #\\B #\\C #\\c)
  323. % (#\\A #\\a #\\b #\\B #\\c #\\C)
  324. % (#\\A #\\a #\\b #\\B #\\C #\\c)
  325. %But I think readers will get the idea from those I've specified. -kmp 27-May-91
  326. \endissue{CHARACTER-PROPOSAL:2-1-1}
  327. \label Affected By:\None.
  328. \label Exceptional Situations::
  329. \Shouldcheckplus{character}
  330. \label See Also::
  331. {\secref\CharacterSyntax},
  332. {\secref\ImplementationDefinedScripts}
  333. \label Notes::
  334. If characters differ in their \term{code} \term{attribute}
  335. or any \term{implementation-defined} \term{attribute},
  336. they are considered to be different by \funref{char=}.
  337. %% 13.2.0 33
  338. There is no requirement that \f{(eq c1 c2)} be true merely because
  339. \f{(char= c1 c2)} is \term{true}. While \funref{eq} can distinguish two
  340. \term{characters}
  341. that \funref{char=} does not, it is distinguishing them not
  342. as \term{characters}, but in some sense on the basis of a lower level
  343. implementation characteristic.
  344. If \f{(eq c1 c2)} is \term{true},
  345. then \f{(char= c1 c2)} is also true.
  346. \funref{eql} and \funref{equal}
  347. compare \term{characters} in the same
  348. way that \funref{char=} does.
  349. The manner in which \term{case} is used by
  350. \funref{char-equal},
  351. \funref{char-not-equal},
  352. \funref{char-lessp},
  353. \funref{char-greaterp},
  354. \funref{char-not-greaterp},
  355. and \funref{char-not-lessp}
  356. implies an ordering for \term{standard characters} such that
  357. \f{A=a}, \f{B=b}, and so on, up to \f{Z=z}, and furthermore either
  358. \f{9<A} or \f{Z<0}.
  359. \endcom
  360. %-------------------- Character Types --------------------
  361. %%% ========== CHARACTER (Function)
  362. \begincom{character}\ftype{Function}
  363. \label Syntax::
  364. \DefunWithValues character {character} {denoted-character}
  365. \label Arguments and Values::
  366. \issue{CHARACTER-PROPOSAL:2-1-1}
  367. \param{character}---a \term{character designator}.
  368. \endissue{CHARACTER-PROPOSAL:2-1-1}
  369. \param{denoted-character}---a \term{character}.
  370. \label Description::
  371. %% 13.4.0 3
  372. Returns the \term{character} denoted by the \param{character} \term{designator}.
  373. \label Examples::
  374. \code
  375. (character #\\a) \EV #\\a
  376. (character "a") \EV #\\a
  377. (character 'a) \EV #\\A
  378. (character '\\a) \EV #\\a
  379. (character 65.) is an error.
  380. (character 'apple) is an error.
  381. \endcode
  382. \label Affected By:\None.
  383. \label Exceptional Situations::
  384. \Shouldchecktype{object}{a \term{character designator}}
  385. \label See Also::
  386. \funref{coerce}
  387. \label Notes::
  388. \code
  389. (character \param{object}) \EQ (coerce \param{object} 'character)
  390. \endcode
  391. \endcom
  392. %%% ========== CHARACTERP
  393. \begincom{characterp}\ftype{Function}
  394. \label Syntax::
  395. \DefunWithValues characterp {object} {generalized-boolean}
  396. \label Arguments and Values::
  397. \param{object}---an \term{object}.
  398. \param{generalized-boolean}---a \term{generalized boolean}.
  399. \label Description::
  400. %% 6.2.2 17
  401. \TypePredicate{object}{character}
  402. \label Examples::
  403. \code
  404. (characterp #\\a) \EV \term{true}
  405. (characterp 'a) \EV \term{false}
  406. (characterp "a") \EV \term{false}
  407. (characterp 65.) \EV \term{false}
  408. (characterp #\\Newline) \EV \term{true}
  409. ;; This next example presupposes an implementation
  410. ;; in which #\\Rubout is an implementation-defined character.
  411. (characterp #\\Rubout) \EV \term{true}
  412. \endcode
  413. \label Affected By:\None.
  414. \label Exceptional Situations:\None!
  415. \label See Also::
  416. \funref{character} (\term{type} and \term{function}), \funref{typep}
  417. \label Notes::
  418. \code
  419. (characterp \param{object}) \EQ (typep \param{object} 'character)
  420. \endcode
  421. \endcom
  422. %-------------------- Character Roles --------------------
  423. %%% ========== ALPHA-CHAR-P
  424. \begincom{alpha-char-p}\ftype{Function}
  425. \label Syntax::
  426. \DefunWithValues alpha-char-p {character} {generalized-boolean}
  427. \label Arguments and Values::
  428. \param{character}---a \term{character}.
  429. \param{generalized-boolean}---a \term{generalized boolean}.
  430. \label Description::
  431. %% 13.2.0 9
  432. \Predicate{character}{an \term{alphabetic}\meaning{1} \term{character}}
  433. \label Examples::
  434. \def\alfa{$\alpha$}
  435. \code
  436. (alpha-char-p #\\a) \EV \term{true}
  437. (alpha-char-p #\\5) \EV \term{false}
  438. (alpha-char-p #\\Newline) \EV \term{false}
  439. ;; This next example presupposes an implementation
  440. ;; in which #\\\alfa is a defined character.
  441. (alpha-char-p #\\\alfa) \EV \term{implementation-dependent}
  442. \endcode
  443. \label Affected By::
  444. None.
  445. (In particular, the results of this predicate are independent
  446. of any special syntax which might have been enabled in the \term{current readtable}.)
  447. \label Exceptional Situations::
  448. \Shouldchecktype{character}{a \term{character}}
  449. \label See Also::
  450. \funref{alphanumericp},
  451. {\secref\ImplementationDefinedScripts}
  452. \label Notes:\None.
  453. \endcom
  454. %%% ========== ALPHANUMERICP
  455. \begincom{alphanumericp}\ftype{Function}
  456. \label Syntax::
  457. \DefunWithValues alphanumericp {character} {generalized-boolean}
  458. \label Arguments and Values::
  459. \param{character}---a \term{character}.
  460. \param{generalized-boolean}---a \term{generalized boolean}.
  461. \label Description::
  462. %% 13.2.0 22
  463. \Predicate{character}{an \term{alphabetic}\meaning{1} \term{character}
  464. or a \term{numeric} \term{character}}
  465. \label Examples::
  466. \code
  467. (alphanumericp #\\Z) \EV \term{true}
  468. (alphanumericp #\\9) \EV \term{true}
  469. (alphanumericp #\\Newline) \EV \term{false}
  470. (alphanumericp #\\#) \EV \term{false}
  471. \endcode
  472. \label Affected By::
  473. None.
  474. (In particular, the results of this predicate are independent
  475. of any special syntax which might have been enabled in the \term{current readtable}.)
  476. \label Exceptional Situations::
  477. \Shouldchecktype{character}{a \term{character}}
  478. \label See Also::
  479. \funref{alpha-char-p}, \funref{graphic-char-p}, \funref{digit-char-p}
  480. \label Notes::
  481. Alphanumeric characters are graphic
  482. as defined by \funref{graphic-char-p}.
  483. The alphanumeric characters are a subset of the graphic characters.
  484. %The bits \term{attribute} of any alphanumeric character is 0.
  485. %% 13.2.0 24
  486. The standard characters \f{A} through \f{Z},
  487. \f{a} through \f{z},
  488. and \f{0} through \f{9} are alphanumeric characters.
  489. \code
  490. (alphanumericp x)
  491. \EQ (or (alpha-char-p x) (not (null (digit-char-p x))))
  492. \endcode
  493. \endcom
  494. %%% ========== DIGIT-CHAR
  495. \begincom{digit-char}\ftype{Function}
  496. \issue{CHARACTER-PROPOSAL:2-1-1}
  497. %% 13.4.0 7
  498. \label Syntax::
  499. \DefunWithValues digit-char {weight {\opt} radix} {char}
  500. \label Arguments and Values::
  501. \param{weight}---a non-negative \term{integer}.
  502. \param{radix}---a \term{radix}.
  503. \Default{\f{10}}
  504. \param{char}---a \term{character} or \term{false}.
  505. \label Description::
  506. %% 13.4.0 8
  507. %% 13.4.0 9
  508. %% 13.4.0 10
  509. % I reorganized this description in a major way because once bits
  510. % were removed, it seemed to have a simpler description. -kmp 23-Apr-91
  511. If \param{weight} is less than \param{radix},
  512. \funref{digit-char} returns a \term{character} which has that \param{weight}
  513. when considered as a digit in the specified radix.
  514. If the resulting \term{character} is to be an \term{alphabetic}\meaning{1} \term{character},
  515. it will be an uppercase \term{character}.
  516. If \param{weight} is greater than or equal to \param{radix},
  517. \funref{digit-char} returns \term{false}.
  518. \label Examples::
  519. \code
  520. (digit-char 0) \EV #\\0
  521. (digit-char 10 11) \EV #\\A
  522. (digit-char 10 10) \EV \term{false}
  523. (digit-char 7) \EV #\\7
  524. (digit-char 12) \EV \term{false}
  525. (digit-char 12 16) \EV #\\C ;not #\\c
  526. (digit-char 6 2) \EV \term{false}
  527. (digit-char 1 2) \EV #\\1
  528. \endcode
  529. \label Affected By:\None.
  530. \label Exceptional Situations:\None.
  531. \label See Also::
  532. \funref{digit-char-p},
  533. \funref{graphic-char-p},
  534. {\secref\CharacterSyntax}
  535. \label Notes::
  536. \endissue{CHARACTER-PROPOSAL:2-1-1}
  537. \endcom
  538. %%% ========== DIGIT-CHAR-P
  539. \begincom{digit-char-p}\ftype{Function}
  540. %% 13.2.0 18
  541. \label Syntax::
  542. \DefunWithValues digit-char-p {char {\opt} radix} {weight}
  543. \label Arguments and Values::
  544. \param{char}---a \term{character}.
  545. \param{radix}---a \term{radix}.
  546. \Default{\f{10}}
  547. \param{weight}---either a non-negative \term{integer} less than \param{radix},
  548. or \term{false}.
  549. \label Description::
  550. Tests whether \param{char} is a digit in the specified \param{radix}
  551. %% 13.2.0 20
  552. (\ie with a weight less than \param{radix}).
  553. If it is a digit in that \param{radix},
  554. its weight is returned as an \term{integer};
  555. otherwise \nil\ is returned.
  556. \label Examples::
  557. \code
  558. (digit-char-p #\\5) \EV 5
  559. (digit-char-p #\\5 2) \EV \term{false}
  560. (digit-char-p #\\A) \EV \term{false}
  561. (digit-char-p #\\a) \EV \term{false}
  562. (digit-char-p #\\A 11) \EV 10
  563. (digit-char-p #\\a 11) \EV 10
  564. (mapcar #'(lambda (radix)
  565. (map 'list #'(lambda (x) (digit-char-p x radix))
  566. "059AaFGZ"))
  567. '(2 8 10 16 36))
  568. \EV ((0 NIL NIL NIL NIL NIL NIL NIL)
  569. (0 5 NIL NIL NIL NIL NIL NIL)
  570. (0 5 9 NIL NIL NIL NIL NIL)
  571. (0 5 9 10 10 15 NIL NIL)
  572. (0 5 9 10 10 15 16 35))
  573. \endcode
  574. %In the above, recall that \EV's arrow takes up about two column positions,
  575. %rather than three characters "\EV" -- so the grinding looks funny here in
  576. %the source, but better on paper.
  577. \label Affected By::
  578. None.
  579. (In particular, the results of this predicate are independent
  580. of any special syntax which might have been enabled in the \term{current readtable}.)
  581. \label Exceptional Situations:\None.
  582. \label See Also::
  583. \funref{alphanumericp}
  584. \label Notes::
  585. %% 13.2.0 19
  586. Digits are \term{graphic} \term{characters}.
  587. \endcom
  588. %%% ========== GRAPHIC-CHAR-P
  589. \begincom{graphic-char-p}\ftype{Function}
  590. \label Syntax::
  591. \DefunWithValues graphic-char-p {char} {generalized-boolean}
  592. \label Arguments and Values::
  593. \param{char}---a \term{character}.
  594. \param{generalized-boolean}---a \term{generalized boolean}.
  595. \label Description::
  596. %% 13.2.0 5
  597. \Predicate{character}{a \term{graphic} \term{character}}
  598. \label Examples::
  599. \code
  600. (graphic-char-p #\\G) \EV \term{true}
  601. (graphic-char-p #\\#) \EV \term{true}
  602. (graphic-char-p #\\Space) \EV \term{true}
  603. (graphic-char-p #\\Newline) \EV \term{false}
  604. \endcode
  605. \label Affected By:\None.
  606. \label Exceptional Situations::
  607. \Shouldchecktype{character}{a \term{character}}
  608. \label See Also::
  609. \funref{read},
  610. {\secref\CharacterSyntax},
  611. {\secref\ImplementationDefinedScripts}
  612. \label Notes:\None.
  613. \endcom
  614. %%% ========== STANDARD-CHAR-P
  615. \begincom{standard-char-p}\ftype{Function}
  616. \label Syntax::
  617. \DefunWithValues standard-char-p {character} {generalized-boolean}
  618. \label Arguments and Values::
  619. \param{character}---a \term{character}.
  620. \param{generalized-boolean}---a \term{generalized boolean}.
  621. \label Description::
  622. %% 13.2.0 3
  623. \TypePredicate{character}{standard-char}
  624. \label Examples::
  625. \code
  626. (standard-char-p #\\Space) \EV \term{true}
  627. (standard-char-p #\\~) \EV \term{true}
  628. ;; This next example presupposes an implementation
  629. ;; in which #\\Bell is a defined character.
  630. (standard-char-p #\\Bell) \EV \term{false}
  631. \endcode
  632. \label Affected By:\None.
  633. \label Exceptional Situations::
  634. \Shouldchecktype{character}{a \term{character}}
  635. \label See Also:\None.
  636. \label Notes:\None.
  637. \endcom
  638. %-------------------- Character Casification --------------------
  639. %%% ========== CHAR-DOWNCASE
  640. %%% ========== CHAR-UPCASE
  641. \begincom{char-upcase, char-downcase}\ftype{Function}
  642. \label Syntax::
  643. \DefunMultiWithValues {character} {corresponding-character}
  644. {\entry{char-upcase}
  645. \entry{char-downcase}}
  646. \label Arguments and Values::
  647. \param{character}, \param{corresponding-character}---a \term{character}.
  648. \label Description::
  649. %% 13.4.0 5
  650. If \param{character} is a \term{lowercase} \term{character},
  651. \funref{char-upcase} returns the corresponding \term{uppercase} \term{character}.
  652. Otherwise, \funref{char-upcase} just returns the given \param{character}.
  653. If \param{character} is an \term{uppercase} \term{character},
  654. \funref{char-downcase} returns the corresponding \term{lowercase} \term{character}.
  655. Otherwise, \funref{char-downcase} just returns the given \param{character}.
  656. \issue{CHARACTER-PROPOSAL:2-1-1}
  657. The result only ever differs from \param{character}
  658. in its \term{code} \term{attribute};
  659. all \term{implementation-defined} \term{attributes} are preserved.
  660. \endissue{CHARACTER-PROPOSAL:2-1-1}
  661. \label Examples::
  662. \code
  663. (char-upcase #\\a) \EV #\\A
  664. (char-upcase #\\A) \EV #\\A
  665. (char-downcase #\\a) \EV #\\a
  666. (char-downcase #\\A) \EV #\\a
  667. (char-upcase #\\9) \EV #\\9
  668. (char-downcase #\\9) \EV #\\9
  669. (char-upcase #\\@) \EV #\\@
  670. (char-downcase #\\@) \EV #\\@
  671. ;; Note that this next example might run for a very long time in
  672. ;; some implementations if CHAR-CODE-LIMIT happens to be very large
  673. ;; for that implementation.
  674. (dotimes (code char-code-limit)
  675. (let ((char (code-char code)))
  676. (when char
  677. (unless (cond ((upper-case-p char) (char= (char-upcase (char-downcase char)) char))
  678. ((lower-case-p char) (char= (char-downcase (char-upcase char)) char))
  679. (t (and (char= (char-upcase (char-downcase char)) char)
  680. (char= (char-downcase (char-upcase char)) char))))
  681. (return char)))))
  682. \EV NIL
  683. \endcode
  684. \label Affected By:\None.
  685. \label Exceptional Situations::
  686. \Shouldchecktype{character}{a \term{character}}
  687. \label See Also::
  688. \funref{upper-case-p},
  689. \funref{alpha-char-p},
  690. {\secref\CharactersWithCase},
  691. {\secref\ImplementationDefinedScripts}
  692. \label Notes::
  693. If the \param{corresponding-char} is \term{different} than \param{character},
  694. then both the \param{character} and the \param{corresponding-char} have \term{case}.
  695. Since \funref{char-equal} ignores the \term{case} of the \term{characters} it compares,
  696. the \param{corresponding-character} is always the \term{same} as \param{character}
  697. under \funref{char-equal}.
  698. \endcom
  699. %%% ========== LOWER-CASE-P
  700. %%% ========== BOTH-CASE-P
  701. %%% ========== UPPER-CASE-P
  702. \begincom{upper-case-p, lower-case-p, both-case-p}\ftype{Function}
  703. \label Syntax::
  704. \DefunMultiWithValues {character} {generalized-boolean}
  705. {\entry{upper-case-p}
  706. \entry{lower-case-p}
  707. \entry{both-case-p}}
  708. \label Arguments and Values::
  709. \param{character}---a \term{character}.
  710. \param{generalized-boolean}---a \term{generalized boolean}.
  711. \label Description::
  712. These functions test the case of a given \param{character}.
  713. %% 13.2.0 13
  714. \NamedPredicate{upper-case-p}{character}{an \term{uppercase} \term{character}}
  715. %% 13.2.0 14
  716. \NamedPredicate{lower-case-p}{character}{a \term{lowercase} \term{character}}
  717. %% 13.2.0 15
  718. \NamedPredicate{both-case-p}{character}{a \term{character} with \term{case}}
  719. \label Examples::
  720. \code
  721. (upper-case-p #\\A) \EV \term{true}
  722. (upper-case-p #\\a) \EV \term{false}
  723. (both-case-p #\\a) \EV \term{true}
  724. (both-case-p #\\5) \EV \term{false}
  725. (lower-case-p #\\5) \EV \term{false}
  726. (upper-case-p #\\5) \EV \term{false}
  727. ;; This next example presupposes an implementation
  728. ;; in which #\\Bell is an implementation-defined character.
  729. (lower-case-p #\\Bell) \EV \term{false}
  730. \endcode
  731. \label Side Effects:\None.
  732. \label Affected By:\None.
  733. \label Exceptional Situations::
  734. \Shouldchecktype{character}{a \term{character}}
  735. \label See Also::
  736. \funref{char-upcase},
  737. \funref{char-downcase},
  738. {\secref\CharactersWithCase},
  739. {\secref\ImplementationDefinedScripts}
  740. \label Notes:\None.
  741. \endcom
  742. %-------------------- Character Codes --------------------
  743. %%% ========== CHAR-CODE
  744. \begincom{char-code}\ftype{Function}
  745. \label Syntax::
  746. \DefunWithValues char-code {character} {code}
  747. \label Arguments and Values::
  748. \param{character}---a \term{character}.
  749. \param{code}---a \term{character code}.
  750. \label Description::
  751. %% 13.3.0 3
  752. \funref{char-code} returns the \term{code} \term{attribute} of \param{character}.
  753. \label Examples::
  754. \code
  755. ;; An implementation using ASCII character encoding
  756. ;; might return these values:
  757. (char-code #\\$) \EV 36
  758. (char-code #\\a) \EV 97
  759. \endcode
  760. \label Affected By:\None.
  761. \label Exceptional Situations::
  762. \Shouldchecktype{character}{a \term{character}}
  763. \label See Also::
  764. \funref{char-code-limit}
  765. \label Notes:\None.
  766. \endcom
  767. %%% ========== CHAR-INT
  768. \begincom{char-int}\ftype{Function}
  769. \label Syntax::
  770. \DefunWithValues char-int {character} {integer}
  771. \label Arguments and Values::
  772. \param{character}---a \term{character}.
  773. \param{integer}---a non-negative \term{integer}.
  774. \label Description::
  775. %% 13.4.0 11
  776. \issue{CHARACTER-PROPOSAL:2-1-2}
  777. Returns a non-negative \term{integer} encoding the \param{character} object.
  778. The manner in which the \term{integer} is computed is \term{implementation-dependent}.
  779. In contrast to \funref{sxhash}, the result is not guaranteed to be independent
  780. of the particular \term{Lisp image}.
  781. \endissue{CHARACTER-PROPOSAL:2-1-2}
  782. %% 13.4.0 12
  783. If \param{character} has no \term{implementation-defined} \term{attributes},
  784. the results of \funref{char-int} and \funref{char-code} are the same.
  785. \code
  786. (char= \i{c1} \i{c2}) \EQ (= (char-int \i{c1}) (char-int \i{c2}))
  787. \endcode
  788. for characters \i{c1} and \i{c2}.
  789. \label Examples::
  790. \code
  791. (char-int #\\A) \EV 65 ; implementation A
  792. (char-int #\\A) \EV 577 ; implementation B
  793. (char-int #\\A) \EV 262145 ; implementation C
  794. \endcode
  795. \label Affected By:\None.
  796. \label Exceptional Situations:\None.
  797. \label See Also::
  798. \funref{char-code}
  799. \label Notes:\None.
  800. \endcom
  801. %%% ========== CODE-CHAR
  802. \begincom{code-char}\ftype{Function}
  803. \issue{CHARACTER-PROPOSAL:2-1-1}
  804. \label Syntax::
  805. \DefunWithValues code-char {code} {char-p}
  806. \label Arguments and Values::
  807. \param{code}---a \term{character code}.
  808. \param{char-p}---a \term{character} or \nil.
  809. \label Description::
  810. %% 13.3.0 6
  811. Returns a \term{character} with the \term{code} \term{attribute} given by \param{code}.
  812. If no such \term{character} exists and one cannot be created, \nil\ is returned.
  813. \label Examples::
  814. \code
  815. (code-char 65.) \EV #\\A ;in an implementation using ASCII codes
  816. (code-char (char-code #\\Space)) \EV #\\Space ;in any implementation
  817. \endcode
  818. %% 13.3.0 7
  819. % Removed per suggestion of Barmar -- used old-style bits/fonts.
  820. \label Affected By::
  821. The \term{implementation}'s character encoding.
  822. \label Exceptional Situations:\None.
  823. \label See Also::
  824. \funref{char-code}
  825. \label Notes::
  826. \endissue{CHARACTER-PROPOSAL:2-1-1}
  827. \endcom
  828. %%% ========== CHAR-CODE-LIMIT
  829. \begincom{char-code-limit}\ftype{Constant Variable}
  830. \label Constant Value::
  831. A non-negative \term{integer}, the exact magnitude of which
  832. is \term{implementation-dependent}, but which is not less
  833. than \f{96} (the number of \term{standard characters}).
  834. \label Description::
  835. %% 13.1.0 2
  836. The upper exclusive bound on the \term{value} returned by
  837. the \term{function} \funref{char-code}.
  838. \label See Also::
  839. \funref{char-code}
  840. \label Notes::
  841. % Sandra wanted this added.
  842. \Thevalueof{char-code-limit} might be larger than the actual
  843. number of \term{characters} supported by the \term{implementation}.
  844. \endcom
  845. %-------------------- Character Names --------------------
  846. %%% ========== CHAR-NAME
  847. \begincom{char-name}\ftype{Function}
  848. \label Syntax::
  849. \DefunWithValues char-name {character} {name}
  850. \label Arguments and Values::
  851. \param{character}---a \term{character}.
  852. \param{name}---a \term{string} or \nil.
  853. \label Description::
  854. Returns a \term{string} that is the \term{name} of the \param{character},
  855. or \nil\ if the \param{character} has no \term{name}.
  856. %% 13.4.0 20
  857. % \funref{char-name} will only locate ``simple'' character names;
  858. % it will not construct names on the basis of
  859. % the \param{character}'s \term{implementation-dependent} \term{attributes}.
  860. All \term{non-graphic} characters are required to have \term{names}
  861. unless they have some \term{implementation-defined} \term{attribute}
  862. which is not \term{null}. Whether or not other \term{characters}
  863. have \term{names} is \term{implementation-dependent}.
  864. \issue{CHAR-NAME-CASE:X3J13-MAR-91}
  865. %% I added this next phrase to highlight why there are two lists here. -kmp 14-May-93
  866. The \term{standard characters}
  867. \NewlineChar\ and \SpaceChar\ have the respective names \f{"Newline"} and \f{"Space"}.
  868. %% Ditto. -kmp 14-May-93
  869. The \term{semi-standard} \term{characters}
  870. \TabChar, \PageChar, \RuboutChar, \LinefeedChar, \ReturnChar, and \BackspaceChar\
  871. %% Next parenthetical remark added for emphasis. -kmp 14-May-93
  872. (if they are supported by the \term{implementation})
  873. have the respective names
  874. \f{"Tab"}, \f{"Page"}, \f{"Rubout"}, \f{"Linefeed"}, \f{"Return"}, and \f{"Backspace"}
  875. (in the indicated case, even though name lookup by ``\f{\#\\}''
  876. and by \thefunction{name-char} is not case sensitive).
  877. \endissue{CHAR-NAME-CASE:X3J13-MAR-91}
  878. \label Examples::
  879. \code
  880. (char-name #\\ ) \EV "Space"
  881. (char-name #\\Space) \EV "Space"
  882. (char-name #\\Page) \EV "Page"
  883. (char-name #\\a)
  884. \EV NIL
  885. \OV "LOWERCASE-a"
  886. \OV "Small-A"
  887. \OV "LA01"
  888. (char-name #\\A)
  889. \EV NIL
  890. \OV "UPPERCASE-A"
  891. \OV "Capital-A"
  892. \OV "LA02"
  893. ;; Even though its CHAR-NAME can vary, #\\A prints as #\\A
  894. (prin1-to-string (read-from-string (format nil "#\\\\~A" (or (char-name #\\A) "A"))))
  895. \EV "#\\\\A"
  896. \endcode
  897. \label Affected By:\None.
  898. \label Exceptional Situations::
  899. \Shouldchecktype{character}{a \term{character}}
  900. \label See Also::
  901. \funref{name-char},
  902. {\secref\PrintingCharacters}
  903. \label Notes::
  904. %% Added "non-graphic" to cover objection by Sandra:
  905. %% Does this mean that if (char-name #\A) = "Capital-A"
  906. %% (print #\A) prints
  907. %% #\Capital-A
  908. %% instead of #\A ???
  909. %% Or does this apply only to non-standard characters.
  910. \term{Non-graphic}
  911. \term{characters} having \term{names} are written by the \term{Lisp printer}
  912. as ``\f{\#\\}'' followed by the their \term{name}; \seesection\PrintingCharacters.
  913. \endcom
  914. %%% ========== NAME-CHAR
  915. \begincom{name-char}\ftype{Function}
  916. \label Syntax::
  917. \DefunWithValues name-char {name} {char-p}
  918. \label Arguments and Values::
  919. %% 13.4.0 17
  920. %% 13.4.0 18
  921. \param{name}---a \term{string designator}.
  922. \param{char-p}---a \term{character} or \nil.
  923. \label Description::
  924. %% 13.4.0 21
  925. Returns the \term{character} \term{object} whose \term{name} is
  926. \param{name} (as determined by \funref{string-equal}---\ie lookup is not case sensitive).
  927. If such a \term{character} does not exist, \nil\ is returned.
  928. \label Examples::
  929. \code
  930. (name-char 'space) \EV #\\Space
  931. (name-char "space") \EV #\\Space
  932. (name-char "Space") \EV #\\Space
  933. (let ((x (char-name #\\a)))
  934. (or (not x) (eql (name-char x) #\\a))) \EV \term{true}
  935. \endcode
  936. \label Affected By:\None.
  937. \label Exceptional Situations::
  938. \Shouldchecktype{name}{a \term{string designator}}
  939. \label See Also::
  940. \funref{char-name}
  941. \label Notes:\None.
  942. \endcom