Next: , Up: Streams


10.1 External Formats

The encodings supported by SBCL as external formats are named by keyword. Each encoding has a canonical name, which will be encoding returned by stream-external-format, and a number of aliases for convenience, as shown in the table below:

:ASCII
:US-ASCII, :ANSI_X3.4-1968, :ISO-646, :ISO-646-US, :|646|
:CP1250
:|cp1250|, :WINDOWS-1250, :|windows-1250|
:CP1251
:|cp1251|, :WINDOWS-1251, :|windows-1251|
:CP1252
:|cp1252|, :WINDOWS-1252, :|windows-1252|
:CP1253
:|cp1253|, :WINDOWS-1253, :|windows-1253|
:CP1254
:|cp1254|
:CP1255
:|cp1255|, :WINDOWS-1255, :|windows-1255|
:CP1256
:|cp1256|, :WINDOWS-1256, :|windows-1256|
:CP1257
:|cp1257|, :WINDOWS-1257, :|windows-1257|
:CP1258
:|cp1258|, :WINDOWS-1258, :|windows-1258|
:CP437
:|cp437|
:CP850
:|cp850|
:CP852
:|cp852|
:CP855
:|cp855|
:CP857
:|cp857|
:CP860
:|cp860|
:CP861
:|cp861|
:CP862
:|cp862|
:CP863
:|cp863|
:CP864
:|cp864|
:CP865
:|cp865|
:CP866
:|cp866|
:CP869
:|cp869|
:CP874
:|cp874|
:EBCDIC-US
:CP037, :|cp037|, :IBM-037, :IBM037
:EUC-JP
:EUCJP, :|eucJP|
:GBK
:CP936
:ISO-8859-10
:|iso-8859-10|, :LATIN-6, :|latin-6|
:ISO-8859-11
:|iso-8859-11|
:ISO-8859-13
:|iso-8859-13|, :LATIN-7, :|latin-7|
:ISO-8859-14
:|iso-8859-14|, :LATIN-8, :|latin-8|
:ISO-8859-2
:|iso-8859-2|, :LATIN-2, :|latin-2|
:ISO-8859-3
:|iso-8859-3|, :LATIN-3, :|latin-3|
:ISO-8859-4
:|iso-8859-4|, :LATIN-4, :|latin-4|
:ISO-8859-5
:|iso-8859-5|
:ISO-8859-6
:|iso-8859-6|
:ISO-8859-7
:|iso-8859-7|
:ISO-8859-8
:|iso-8859-8|
:ISO-8859-9
:|iso-8859-9|, :LATIN-5, :|latin-5|
:KOI8-R
:|koi8-r|
:KOI8-U
:|koi8-u|
:LATIN-1
:LATIN1, :ISO-8859-1, :ISO8859-1
:LATIN-9
:LATIN9, :ISO-8859-15, :ISO8859-15
:SHIFT_JIS
:SJIS, :|Shift_JIS|, :CP932
:UCS-2BE
:UCS2BE
:UCS-2LE
:UCS2LE
:UCS-4BE
:UCS4BE
:UCS-4LE
:UCS4LE
:UTF-16BE
:UTF16BE
:UTF-16LE
:UTF16LE
:UTF-32BE
:UTF32BE
:UTF-32LE
:UTF32LE
:UTF-8
:UTF8
:X-MAC-CYRILLIC
:|x-mac-cyrillic|

In situations where an external file format designator is required, such as the :external-format argument in calls to open or with-open-file, users may supply the name of an encoding to denote the external format which is applying that encoding to Lisp characters.

In addition to the basic encoding for an external format, options controlling various special cases may be passed, by using a list (whose first element must be an encoding name and whose rest is a plist) as an external file format designator. At present, the only supported key in the plist is :replacement, where the corresponding value is a string designator which is used as a replacement when an encoding or decoding error happens, handling those errors without user intervention; for example:

     (with-open-file (i pathname :external-format '(:utf-8 :replacement #\?))
       (read-line i))

will read the first line of pathname, replacing any invalid utf-8 sequences with question marks.