Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[f5afd6]: ansi_streams.xml Maximize Restore History

Download this file

ansi_streams.xml    338 lines (306 with data), 13.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE book [
<!ENTITY % eclent SYSTEM "ecl.ent">
%eclent;
]>
<book xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="en">
<chapter xml:id="ansi.streams">
<title>Streams</title>
<section xml:id="ansi.streams.ansi">
<title>ANSI Streams</title>
<section xml:id="ansi.streams.types">
<title>Supported types</title>
<para>&ECL; implements all stream types described in &ANSI;. Additionally,
when configured with option <option>--enable-clos-streams</option>, &ECL;
includes a version of Gray streams where any object that implements the
appropiate methods (<function>stream-input-p</function>,
<function>stream-read-char</function>, etc) is a valid argument for the
functions that expect streams, such as <function>read</function>,
<function>print</function>, etc.</para>
</section>
<section xml:id="ansi.streams.io">
<title>Element types</title>
<para>&ECL; distinguishes between two kinds of streams: character streams and byte streams. <emphasis>Character streams</emphasis> only accept and produce characters, written or read one by one, with <function>write-char</function> or <function>read-char</function>, or in chunks, with <function>write-sequence</function> or any of the Lisp printer functions. Character operations are conditioned by the external format, as described in <xref linkend="ansi.streams.formats"/></para>
<para>ANSI Common Lisp also supports binary streams. Here input and output is performed in chunks of bits. Binary streams are created with the function <function>open</function> passing as argument a subtype of <type>integer</type> and the implementation is free to round up that integer type to the closest size it supports. In particular &ECL; rounds up the size to a multiple of a byte. For example, the form <code>(open "foo.bin" :direction :output :element-type '(unsigned-byte 13))</code>, will open the file <filename>foo.bin</filename> for writing, using 16-bit words as the element type.</para>
</section>
<section xml:id="ansi.streams.formats">
<title>External formats</title>
<para>An <emphasis>external format</emphasis> is an encoding for characters that maps character codes to a sequence of bytes, in a one-to-one or one-to-many fashion. External formats are also known as "character encodings" in the programming world and are an essential ingredient to be able to read and write text in different languages and alphabets.</para>
<para>&ECL; has one of the most complete supports for <emphasis>external formats</emphasis>, covering all of the usual codepages from the Windows and Unix world, up to the more recent <acronym>UTF-8</acronym>, <acronym>UCS-2</acronym> and <acronym>UCS-4</acronym> formats, all of them with big and small endian variants, and considering different encodings for the newline character.</para>
<para>However, the set of supported external formats depends on the size of the space of character codes. When &ECL; is built with Unicode support (the default option), it can represent all known characters from all known codepages, and thus all external formats are supported. However, when &ECL; is built with the restricted character set, it can only use one codepage (the one provided by the C library), with a few variants for the representation of end-of-line characters.</para>
<para>In &ECL;, an external format designator is defined recursively as either a symbol or a list of symbols. The grammar is as follows
<screen>external-format-designator :=
symbol |
( {symbol}+ )
</screen>
and the table of known symbols is shown below. Note how some symbols (<code>:cr</code>, <code>:little-endian</code>, etc) just modify other external formats.</para>
<table xml:id="table.external-formats">
<title>Stream external formats</title>
<tgroup cols="3">
<thead>
<row>
<entry>Symbols</entry>
<entry>Codepage or encoding</entry>
<entry>Unicode required</entry>
</row>
</thead>
<tbody>
<row>
<entry><symbol>:cr</symbol></entry>
<entry><code>#\Newline</code> is Carriage Return</entry>
<entry>No</entry>
</row>
<row>
<entry><symbol>:crlf</symbol></entry>
<entry><code>#\Newline</code> is Carriage Return followed by Linefeed</entry>
<entry>No</entry>
</row>
<row>
<entry><symbol>:lf</symbol></entry>
<entry><code>#\Newline</code> is Linefeed</entry>
<entry>No</entry>
</row>
<row>
<entry><symbol>:little-endian</symbol></entry>
<entry>Modify <acronym>UCS</acronym> to use little endian encoding.</entry>
<entry>No</entry>
</row>
<row>
<entry><symbol>:big-endian</symbol></entry>
<entry>Modify <acronym>UCS</acronym> to use big endian encoding.</entry>
<entry>No</entry>
</row>
<row>
<entry><symbol>:utf-8</symbol> <symbol>ext:utf8</symbol></entry>
<entry>Unicode <acronym>UTF-8</acronym></entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>:ucs-2</symbol> <symbol>ext:ucs2</symbol> <symbol>ext:utf-16</symbol> <symbol>ext:utf16</symbol>
<symbol>ext:unicode</symbol></entry>
<entry><acronym>UCS-2</acronym> encoding with <acronym>BOM</acronym>.</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>:ucs-2le</symbol> <symbol>ext:ucs2le</symbol> <symbol>ext:utf-16le</symbol></entry>
<entry><acronym>UCS-2</acronym> with big-endian encoding</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>:ucs-2be</symbol> <symbol>ext:ucs2be</symbol> <symbol>ext:utf-16be</symbol></entry>
<entry><acronym>UCS-2</acronym> with big-endian encoding</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>:ucs-4</symbol> <symbol>ext:ucs4</symbol> <symbol>ext:utf-32</symbol> <symbol>ext:utf32</symbol></entry>
<entry><acronym>UCS-4</acronym> encoding with <acronym>BOM</acronym>.</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>:ucs-4le</symbol> <symbol>ext:ucs4le</symbol> <symbol>ext:utf-32le</symbol></entry>
<entry><acronym>UCS-4</acronym> with big-endian encoding</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>:ucs-4be</symbol> <symbol>ext:ucs4be</symbol> <symbol>ext:utf-32be</symbol></entry>
<entry><acronym>UCS-4</acronym> with big-endian encoding</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:iso-8859-1</symbol> <symbol>ext:iso8859-1</symbol> <symbol>ext:latin-1</symbol> <symbol>ext:cp819</symbol> <symbol>ext:ibm819</symbol></entry>
<entry>Latin-1 encoding</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:iso-8859-2</symbol> <symbol>ext:iso8859-2</symbol> <symbol>ext:latin-2</symbol> <symbol>ext:latin2</symbol></entry>
<entry>Latin-2 encoding</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:iso-8859-3</symbol> <symbol>ext:iso8859-3</symbol> <symbol>ext:latin-3</symbol> <symbol>ext:latin3</symbol></entry>
<entry>Latin-3 encoding</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:iso-8859-4</symbol> <symbol>ext:iso8859-4</symbol> <symbol>ext:latin-4</symbol> <symbol>ext:latin4</symbol></entry>
<entry>Latin-4 encoding</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:iso-8859-5</symbol> <symbol>ext:cyrillic</symbol></entry>
<entry>Latin-5 encoding</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:iso-8859-6</symbol> <symbol>ext:arabic</symbol> <symbol>ext:asmo-708</symbol> <symbol>ext:ecma-114</symbol></entry>
<entry>Latin-6 encoding</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:iso-8859-7</symbol> <symbol>ext:greek8</symbol> <symbol>ext:greek</symbol> <symbol>ext:ecma-118</symbol></entry>
<entry>Greek encoding</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:iso-8859-8</symbol> <symbol>ext:hebrew</symbol></entry>
<entry>Hebrew encoding</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:iso-8859-9</symbol> <symbol>ext:latin-5</symbol> <symbol>ext:latin5</symbol></entry>
<entry>Latin-5 encoding</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:iso-8859-10</symbol> <symbol>ext:iso8859-10</symbol> <symbol>ext:latin-6</symbol> <symbol>ext:latin6</symbol></entry>
<entry>Latin-6 encoding</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:iso-8859-13</symbol> <symbol>ext:iso8859-13</symbol> <symbol>ext:latin-7</symbol> <symbol>ext:latin7</symbol></entry>
<entry>Latin-7 encoding</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:iso-8859-14</symbol> <symbol>ext:iso8859-14</symbol> <symbol>ext:latin-8</symbol> <symbol>ext:latin8</symbol></entry>
<entry>Latin-8 encoding</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:iso-8859-15</symbol> <symbol>ext:iso8859-15</symbol> <symbol>ext:latin-9</symbol> <symbol>ext:latin9</symbol></entry>
<entry>Latin-7 encoding</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:dos-cp437</symbol> <symbol>ext:ibm-437</symbol></entry>
<entry>IBM CP 437</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:dos-cp850</symbol> <symbol>ext:ibm-850</symbol> <symbol>ext:cp850</symbol></entry>
<entry>Windows CP 850</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:dos-cp852</symbol> <symbol>ext:ibm-852</symbol></entry>
<entry>IBM CP 852</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:dos-cp855</symbol> <symbol>ext:ibm-855</symbol></entry>
<entry>IBM CP 855</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:dos-cp860</symbol> <symbol>ext:ibm-860</symbol></entry>
<entry>IBM CP 860</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:dos-cp861</symbol> <symbol>ext:ibm-861</symbol></entry>
<entry>IBM CP 861</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:dos-cp862</symbol> <symbol>ext:ibm-862</symbol> <symbol>ext:cp862</symbol></entry>
<entry>Windows CP 862</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:dos-cp863</symbol> <symbol>ext:ibm-863</symbol></entry>
<entry>IBM CP 863</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:dos-cp864</symbol> <symbol>ext:ibm-864</symbol></entry>
<entry>IBM CP 864</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:dos-cp865</symbol> <symbol>ext:ibm-865</symbol></entry>
<entry>IBM CP 865</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:dos-cp866</symbol> <symbol>ext:ibm-866</symbol> <symbol>ext:cp866</symbol></entry>
<entry>Windows CP 866</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:dos-cp869</symbol> <symbol>ext:ibm-869</symbol></entry>
<entry>IBM CP 869</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:windows-cp932</symbol> <symbol>ext:windows-932</symbol> <symbol>ext:cp932</symbol></entry>
<entry>Windows CP 932</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:windows-cp936</symbol> <symbol>ext:windows-936</symbol> <symbol>ext:cp936</symbol></entry>
<entry>Windows CP 936</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:windows-cp949</symbol> <symbol>ext:windows-949</symbol> <symbol>ext:cp949</symbol></entry>
<entry>Windows CP 949</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:windows-cp950</symbol> <symbol>ext:windows-950</symbol> <symbol>ext:cp950</symbol></entry>
<entry>Windows CP 950</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:windows-cp1250</symbol> <symbol>ext:windows-1250</symbol> <symbol>ext:ms-ee</symbol></entry>
<entry>Windows CP 1250</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:windows-cp1251</symbol> <symbol>ext:windows-1251</symbol> <symbol>ext:ms-cyrl</symbol></entry>
<entry>Windows CP 1251</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:windows-cp1252</symbol> <symbol>ext:windows-1252</symbol> <symbol>ext:ms-ansi</symbol></entry>
<entry>Windows CP 1252</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:windows-cp1253</symbol> <symbol>ext:windows-1253</symbol> <symbol>ext:ms-greek</symbol></entry>
<entry>Windows CP 1253</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:windows-cp1254</symbol> <symbol>ext:windows-1254</symbol> <symbol>ext:ms-turk</symbol></entry>
<entry>Windows CP 1254</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:windows-cp1255</symbol> <symbol>ext:windows-1255</symbol> <symbol>ext:ms-hebr</symbol></entry>
<entry>Windows CP 1255</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:windows-cp1256</symbol> <symbol>ext:windows-1256</symbol> <symbol>ext:ms-arab</symbol></entry>
<entry>Windows CP 1256</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:windows-cp1257</symbol> <symbol>ext:windows-1257</symbol> <symbol>ext:winbaltrim</symbol></entry>
<entry>Windows CP 1257</entry>
<entry>Yes</entry>
</row>
<row>
<entry><symbol>ext:windows-cp1258</symbol> <symbol>ext:windows-1258</symbol></entry>
<entry>Windows CP 1258</entry>
<entry>Yes</entry>
</row>
</tbody>
</tgroup>
</table>
</section>
</section>
<xi:include href="ref_c_streams.xml" xpointer="ansi.streams.c-dict" xmlns:xi="http://www.w3.org/2001/XInclude"/>
</chapter>
</book>