Go to the previous, next section.

IO on Lists of Character Codes

This package defines IO predicates that read from, or write to, a list of character codes (a string). There are also predicates to open a stream referring to a list of character codes. The stream may be used with general Stream IO predicates.

To load the package, enter the query

| ?- use_module(library(charsio)).

@
@
Prints Arguments into a list of character codes using format/3 (see section Input and Output of Terms). Chars is unified with the list, alternatively S0 and S are unified with the head and tail of the list, respectively.

@
@
A specialized format_to_chars/(3-4). Writes Term into a list of character codes using write/2 (see section Input and Output of Terms). Chars is unified with the list, alternatively S0 and S are unified with the head and tail of the list, respectively.

@
@
A specialized format_to_chars/(3-4). Converts Atom to the list of characters comprising its name. Chars is unified with the list, alternatively S0 and S are unified with the head and tail of the list, respectively.

@
@
A specialized format_to_chars/(3-4). Converts Number to the list of characters comprising its name. Chars is unified with the list, alternatively S0 and S are unified with the head and tail of the list, respectively.

@
Reads Term from Chars using read/2. The Chars must, as usual, be terminated by a full-stop, i.e. a ., possibly followed by layout-text.

@
Stream is opened as an input stream to an existing list of character codes. The stream may be read with the Stream IO predicates and must be closed using close/1. The list is copied to an internal buffer when the stream is opened and therefore be a ground list of character codes at that point.

@
@
Goal is called with the current_output stream set to a new stream. This stream writes to an internal buffer which is, after the successful execution of Goal, converted to a list of character codes. Chars is unified with the list, alternatively S0 and S are unified with the head and tail of the list, respectively.

Go to the previous, next section.