| Did you know ... | Search Documentation: |
| Primitive character I/O |
See section 4.2 for an overview of supported character representations.
put(10).0xD800...0xDFFF)
are rejected, see
section 2.18. Note
that this may also raise an exception if the encoding of the output
stream cannot represent Code.user and the
cursor is not at the left margin.user. See also flush_output/[0,1].end_of_file.update.[]).
This predicate is intended for efficient unbuffered copying and
filtering of input coming from network connections or devices. It also
enables the library library(pure_input), which processes
input from files and streams using a DCG.
The following code fragment realises efficient non-blocking copying of data from an input to an output stream. The at_end_of_stream/1 call checks for end-of-stream and fills the input buffer. Note that the use of a get_code/2 and put_code/2 based loop requires a flush_output/1 call after each put_code/2. The copy_stream_data/2 does not allow for inspection of the copied data and suffers from the same buffering issues.
copy(In, Out) :-
repeat,
fill_buffer(In),
read_pending_codes(In, Chars, Tail),
\+ \+ ( Tail = [],
format(Out, '~s', [Chars]),
flush_output(Out)
),
( Tail == []
-> !
; fail
).