IOSTREAM has a field encoding that is
managed at initialization from SIO_TEXT. The available
encodings are defined as a C enum as below.
typedef enum
{ ENC_UNKNOWN = 0, /* invalid/unknown */
ENC_OCTET, /* raw 8 bit input */
ENC_ASCII, /* US-ASCII (0..127) */
ENC_ISO_LATIN_1, /* ISO Latin-1 (0..256) */
ENC_ANSI, /* default (multibyte) codepage */
ENC_UTF8,
ENC_UNICODE_BE, /* big endian unicode file */
ENC_UNICODE_LE, /* little endian unicode file */
ENC_WCHAR /* wchar_t */
} IOENC;
Binary streams always have the encoding ENC_OCTET.
The default encoding of a text stream depends on the Prolog flag
encoding. The
encoding is used by all functions that perform text I/O on a stream. The
encoding can be changed at any moment using Ssetenc()
which is available from Prolog using the set_stream/2
encoding(Encoding) property. Functions that explicitly
manage the encoding are:
NULL, return the old encoding. This function may
fail, returning -1 if the Scontrol_function() of the stream
returns -1 on the SIO_SETENCODING request. On success it
returns 0. If
new_enc is ENC_OCTET the stream is switched to
binary mode. Otherwise text mode is enabled.SIO_BOM
is set on the stream. Possibly resulting encodings are ENC_UTF8,
ENC_UNICODE_BE and ENC_UNICODE_LE.ENC_UTF8, ENC_UNICODE_BE
or
ENC_UNICODE_LE it writes the code point \ufeff
(a zero-width white space) to the stream in the current encoding and
sets the SIO_BOM flag on the stream.