| Allegro CL version 9.0 Unrevised from 8.2 to 9.0. 8.2 version |
Arguments: stream
This function queries the stream's external-format to obtain information on the end-of-line convention being used. It returns two values: a symbol indicating the end-of-line convention and an external-format.
The first returned value is one of the following values:
:dos
: stream's external
format is a composed external format with a DOS-style end-of-line
convention (carriage-return linefeed at the end of each line).
:mac
: stream's external
format is a composed external format with a Macintosh-style
end-of-line convention (carriage-return but no linefeed at the end of
each line).
:unix
: stream's
external format is not a composed external format and has a UNIX-style
end-of-line convention (linefeed but no carriage return).
:anynl-unix
: on input, any convention
(dos-style carriage-return linefeed, unix-style linefeed and mac-style
carriage-return) is correctly read and converted to a Lisp
#\newline
. On output, #\newline
s
are converted to linefeed (unix-style).
:anynl-dos
: on input, any convention
(dos-style carriage-return linefeed, unix-style linefeed and mac-style
carriage-return) is correctly read and converted to a Lisp
#\newline
. On output, #\newline
s
are converted to carriage-return linefeed (dos-style).
:anynl-mac
: on input, any convention
(dos-style carriage-return linefeed, unix-style linefeed and mac-style
carriage-return) is correctly read and converted to a Lisp
#\newline
. On output, #\newline
s
are converted to carriage-return (mac-style).
The nature of the second returned value depends on whether
stream's external format is or is not a
composed external format. If stream's external
format is not a composed external format (i.e. the first returned
value is :unix
), stream's
external format is returned as the second returned value. If
stream's external format is a composed external
format, the second returned value is the composee (which translates
Lisp characters to octets) external format. This allows easy
construction of a new composed external format based on
stream's, if desired. Composed external formats
are described in Composed External-Formats.
You can change the end-of-line convention using setf and this function. Specify one of the
keywords specified above as the first return value or specify the
keyword :anynl
. When you specify
:anynl
, no change is made if the first return value
is :anynl-unix
, :anynl-dos
, or
:anynl-mac
, and :unix
is changed
to :anynl-unix
, :dos
is changed
to :anynl-dos
, and :mac
is
changed to :anynl-mac
(and the second returned value
is changed appropriately).
The :anynl
value allows you to have streams read
files using any standard end of line convention while still writing
files using the machine-appropriate convention. This makes importing
files for input much easier.
The eol-convention of a stream may be modified if you explicitly set the external format of a stream and so you may have to reset the eol-convention to the desired value.
[On Windows] (setq s (open "c:/autoexec.bat")) -> stream ;; The stream is currently set to read/write Ascii 13 followed by Ascii 10 ;; as/for #\newline. (eol-convention s) -> :dos #<external-format ...> ;; Set the stream so that it reads/writes Ascii 13 as/for #\newline (setf (eol-convention s) :mac) -> :mac #<external-format ...> ;; Set the stream so that it reads/writes Ascii 10 as/for #\newline (setf (eol-convention s) :unix) -> :unix #<external-format ...> [On Unix] (setq s (open "/etc/passwd")) ;; The stream is currently set to read/write Ascii 10 as/for #\newline (eol-convention s) -> :unix #<external-format ...> ;; Set the stream so that it reads/writes Ascii 13 followed by ;; Ascii 10 as/for #\newline. (setf (eol-convention s) :dos) -> :dos #<external-format ...> ;; Set the stream so that it reads/writes Ascii 13 as/for #\newline (setf (eol-convention s) :mac) -> :mac #<external-format ...> ;; Set the stream so that it reads any standard end of line ;; and writes Ascii 13 for #\newline (setf (eol-convention s) :anynl-mac) -> :anynl-mac #<external-format ...> ;; Set the stream to the UNIX default (setf (eol-convention s) :unix) ;; Set the stream so that it reads any standard end of line ;; and writes Ascii 10 for #\newline (setf (eol-convention s) :anynl) -> :anynl-unix #<external-format ...>
See also #\newline discussion.
Copyright (c) 1998-2019, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.2 page.
Created 2012.5.30.
| Allegro CL version 9.0 Unrevised from 8.2 to 9.0. 8.2 version |