Provides a safe encoding which corresponds to the current code page on Microsoft Windows, and the locale on Unix.
system
safe-locale-file-encoding pathname ef-spec buffer length => new-ef-spec
pathname⇩ |
Pathname identifying location of buffer. |
ef-spec⇩ |
An external format spec. |
buffer⇩ |
A buffer whose contents are examined. |
length⇩ |
Length (an integer) up to which buffer should be examined. |
new-ef-spec |
Default external format spec created by merging ef-spec with the encoding that was found to be valid. |
The function safe-locale-file-encoding
is similar to locale-file-encoding except that it always returns a safe external format. That is, the external format does not signal error on writing characters not in the encoding.
On Microsoft Windows, safe-locale-file-encoding
consults the ANSI code page. If the code page identifier id is in win32:*latin-1-code-pages*, it merges ef-spec with :latin-1-safe
. This external format writes Latin-1 on output, using 63 (ASCII '?') to replace any non-Latin-1 characters that are written. If the code page identifier id is not in win32:*latin-1-code-pages* then safe-locale-file-encoding
merges ef-spec with an encoding corresponding to the current code page that uses the code page's replacement code for characters that cannot be encoded.
safe-locale-file-encoding
merges ef-spec with :latin-1-safe
on Unix.
pathname, buffer and length are ignored.
*file-encoding-detection-algorithm*
*latin-1-code-pages*
locale-file-encoding
LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:31:02