| 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <!DOCTYPE book [ |
| 3 | <!ENTITY % eclent SYSTEM "ecl.ent"> |
| 4 | %eclent; |
| 5 | ]> |
| 6 | <book xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="en"> |
| 7 | <chapter xml:id="ansi.characters"> |
| 8 | <title>Characters</title> |
| 9 | <para>&ECL; is fully ANSI Common-Lisp compliant in all aspects of the character |
| 10 | data type, with the following peculiarities.</para> |
| 11 | |
| 12 | <section xml:id="ansi.characeer.unicode"> |
| 13 | <title>Unicode vs. POSIX locale</title> |
| 14 | |
| 15 | <para>There are two ways of building &ECL;: with C or with Unicode character codes. These build modes are accessed using the <code>--disable-unicode</code> and <code>--enable-unicode</code> configuration options, the last one being the default.</para> |
| 16 | |
| 17 | <para>When using C characters we are actually relying on the <type>char</type> type of the C language, using the C library functions for tasks such as character conversions, comparison, etc. In this case characters are typically 8 bit wide and the character order and collation are determines by the current POSIX or C locale. This is not very accurate, leaves out many languages and character encodings but it is sufficient for small applications that do not need multilingual support.</para> |
| 18 | |
| 19 | <para>When no option is specified &ECL; builds with support for a larger character set, the Unicode 6.0 standard. This uses 24 bit large character codes, also known as <emphasis>codepoints</emphasis>, with a large database of character properties which include their nature (alphanumeric, numeric, etc), their case, their collation properties, whether they are standalone or composing characters, etc.</para> |
| 20 | |
| 21 | <section xml:id="ansi.character-types"> |
| 22 | <title>Character types</title> |
| 23 | |
| 24 | <para>If compiled without Unicode support, &ECL; all characters are |
| 25 | implemented using 8-bit codes and the type <type>extended-char</type> |
| 26 | is empty. If compiled with Unicode support, characters are implemented |
| 27 | using 24 bits and the <type>extended-char</type> type covers characters above |
| 28 | code 255.</para> |
| 29 | <informaltable> |
| 30 | <tgroup cols="3"> |
| 31 | <thead> |
| 32 | <row> |
| 33 | <entry>Type</entry> |
| 34 | <entry>With Unicode</entry> |
| 35 | <entry>Without Unicode</entry> |
| 36 | </row> |
| 37 | </thead> |
| 38 | <tbody> |
| 39 | <row> |
| 40 | <entry><type>standard-char</type></entry> |
| 41 | <entry>#\Newline,32-126</entry> |
| 42 | <entry>#\Newline,32-126</entry> |
| 43 | </row> |
| 44 | <row> |
| 45 | <entry><type>base-char</type></entry> |
| 46 | <entry>0-255</entry> |
| 47 | <entry>0-255</entry> |
| 48 | </row> |
| 49 | <row> |
| 50 | <entry><type>extended-char</type></entry> |
| 51 | <entry>256-16777215</entry> |
| 52 | <entry>-</entry> |
| 53 | </row> |
| 54 | </tbody> |
| 55 | </tgroup> |
| 56 | </informaltable> |
| 57 | </section> |
| 58 | |
| 59 | <section xml:id="ansi.character-names"> |
| 60 | <title>Character names</title> |
| 61 | |
| 62 | <para>All characters have a name. For non-printing characters between 0 and 32, and for 127 we use the ordinary <acronym>ASCII</acronym> names. Characters above 127 are printed and read using hexadecimal Unicode notation, with a <literal>U</literal> followed by 24 bit hexadecimal number, as in <literal>U0126</literal>.</para> |
| 63 | <table xml:id="table.character-names"> |
| 64 | <title>Examples of character names</title> |
| 65 | <tgroup cols="2"> |
| 66 | <thead> |
| 67 | <row> |
| 68 | <entry>Character</entry> |
| 69 | <entry>Code</entry> |
| 70 | </row> |
| 71 | </thead> |
| 72 | <tbody> |
| 73 | <row><entry><literal>#\Null</literal></entry><entry>0</entry></row> |
| 74 | <row><entry><literal>#\Ack</literal></entry><entry>1</entry></row> |
| 75 | <row><entry><literal>#\Bell</literal></entry><entry>7</entry></row> |
| 76 | <row><entry><literal>#\Backspace</literal></entry><entry>8</entry></row> |
| 77 | <row><entry><literal>#\Tab</literal></entry><entry>9</entry></row> |
| 78 | <row><entry><literal>#\Newline</literal></entry><entry>10</entry></row> |
| 79 | <row><entry><literal>#\Linefeed</literal></entry><entry>10</entry></row> |
| 80 | <row><entry><literal>#\Page</literal></entry><entry>12</entry></row> |
| 81 | <row><entry><literal>#\Esc</literal></entry><entry>27</entry></row> |
| 82 | <row><entry><literal>#\Escape</literal></entry><entry>27</entry></row> |
| 83 | <row><entry><literal>#\Space</literal></entry><entry>32</entry></row> |
| 84 | <row><entry><literal>#\Rubout</literal></entry><entry>127</entry></row> |
| 85 | <row><entry><literal>#\U0080</literal></entry><entry>128</entry></row> |
| 86 | </tbody> |
| 87 | </tgroup> |
| 88 | </table> |
| 89 | <para>Note that <literal>#\Linefeed</literal> is synonymous with |
| 90 | <literal>#\Newline</literal> and thus is a member of |
| 91 | <type>standard-char</type>.</para> |
| 92 | </section> |
| 93 | </section> |
| 94 | |
| 95 | <section> |
| 96 | <title><code>#\Newline</code> characters</title> |
| 97 | |
| 98 | <para>Internally, &ECL; represents the <literal>#\Newline</literal> character by a single code. However, when using external formats, &ECL; may parse character pairs as a single <literal>#\Newline</literal>, and viceversa, use multiple characters to represent a single <literal>#\Newline</literal>. See <xref linkend="ansi.streams.formats"/>.</para> |
| 99 | </section> |
| 100 | |
| 101 | <xi:include href="ref_c_characters.xml" xpointer="ansi.characters.c-dict" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 102 | </chapter> |
| 103 | </book> |