stream-external-format
stream-external-format Function
Syntax:
stream-external-format stream → format
Arguments and Values:
stream—a file stream.
format—an external file format.
Description:
Returns an external file format designator for the stream.
Examples:
(with-open-file (stream "test" :direction :output)
(stream-external-format stream))
→ :DEFAULT
<i><sup>or</sup>→</i> :ISO8859/1-1987
<i><sup>or</sup>→</i> (:ASCII :SAIL)
<i><sup>or</sup>→</i> ACME::PROPRIETARY-FILE-FORMAT-17
<i><sup>or</sup>→</i> #<FILE-FORMAT :ISO646-1983 2343673>
See Also:
the :external-format argument to the function open and the with-open-file macro.
Notes:
The format returned is not necessarily meaningful to other implementations.
Expanded Reference: stream-external-format
Basic Usage
stream-external-format returns an external file format designator for a file stream. The only standardized value is :DEFAULT.
(with-open-file (s "/tmp/cl-sef-test.txt"
:direction :output :if-exists :supersede)
(stream-external-format s))
=> :UTF-8
Implementation-Dependent Values
The returned value is implementation-dependent and may vary. It could be a keyword, list, or other object.
;; The following shows what a particular implementation might return.
;; Actual results vary:
;; :DEFAULT
;; :UTF-8
;; :ISO-8859-1
;; (:ASCII :SAIL)
With Explicit External Format
When opening a file with an explicit external format, stream-external-format reflects that choice.
(with-open-file (s "/tmp/cl-sef-test.txt"
:direction :output
:if-exists :supersede
:external-format :default)
(stream-external-format s))
=> :UTF-8
Not Meaningful for Binary Streams
The external format is meaningful for character streams. For binary streams, the result is implementation-dependent.