:external-format argument of open and related functions should be an ef-spec, where the name can be
:default. The symbol
:default is the default value.
If you know the format of the data when doing file I/O, you should definitely specify external-format explicitly, in the ef-spec syntax described in this section.
This is the default on Unix/Linux/FreeBSD/Mac OS X systems, meaning that lines are terminated by Linefeed.
This is the default on Windows, meaning that lines are terminated by Carriage-Return followed by Linefeed.
Lines are terminated by Carriage-Return.
If open or
with-open-file gets a complete
:external-format argument then, it is used as is. For example, this form opens an ASCII linefeed-terminated stream:
The default behavior of guess-external-format is as follows:
:default, this finds a match based on the filename; or (if that fails), looks in the Emacs-style (-*-) attribute line for an option called ENCODING or EXTERNAL-FORMAT or CODING; or (if that fails), chooses from amongst likely encodings by analysing the bytes near the start of the file, or (if that fails) uses a default encoding. Otherwise ef-spec's name is assumed to name an encoding and this encoding is used.
:eol-styleparameter, it then also analyses the start of the file for byte patterns indicating the end-of-line style, and uses a default end-of-line style if no such pattern is found.
If element-type is not
:default, checks are made to ensure that the resulting stream's stream-element-type is compatible with its external format:
:io, the element-type argument must be a supertype of the type of characters produced by the external format.
:io, the element-type argument must be a subtype of the type of characters accepted by the external format
If element-type is
:default the system chooses the stream-element-type on the basis of the external format.
The LispWorks Editor uses open with :
element-type :default to read and write files. On reading a file, the external format is remembered and used when saving the file. On writing a Unicode (UTF-16) file, the Byte Order Mark is written.
It is possible to insert characters in the Editor (for example by pasting clipboard text) which are not supported by the chosen external format. This will lead to errors on attempt to save the buffer. You can handle this by setting the external format appropriately.
The Unicode Byte Order Mark (BOM) is treated as whitespace in the default readtable. This allows the Lisp reader to read a 16-bit (UTF-16 or BMP encoded) file regardless of whether the BOM is present. See 16-bit External formats guide for more information.
LispWorks User Guide and Reference Manual - 13 Feb 2015