RT_RAT_NATURAL
PL_WRT_CHARESCAPES_UNICODE
PL_WRT_QUOTE_NON_ASCII
PL_WRT_PARTIAL
For example, to print a term to user_error
as the
toplevel does, use
PL_write_term(Suser_error, t, 1200, PL_WRT_QUOTED|PL_WRT_PORTRAY| PL_WRT_VARNAMES|PL_WRT_NEWLINE)
12.9.4 Foreign stream error handling
- int Sferror(IOSTREAM *s)
- Returns
TRUE
if the stream is in an error condition,FALSE
if the stream is valid and in normal condition and -1 if the stream is invalid. - void Sclearerr(IOSTREAM *s)
- Clear the error state of a stream. This includes the end-of-file state, pending warnings and errors and timeout.
- int Sseterr(IOSTREAM *s, int which, const char *message)
- Set an error or warning state on the stream. The which
argument is one of
SIO_WARN
orSIO_FERR
. This causes PL_release_stream() to print a message (SIO_WARN
) or raise an exception (SIO_FERR
). - int Sset_exception(IOSTREAM *s, term_t ex)
- Associate a Prolog exception term with the stream or clear the
associated exception if ex is 0 and set/clear the
SIO_FERR
condition on the stream. If an exception is assocated PL_release_stream() raises this exception.
12.9.5 Foreign stream encoding
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