Documentation Prolog Predicate Reference builtin peek_byte/2

peek_byte/2

Read byte from input stream without removing it.

Description

peek_byte(Stream, Byte) reads the next byte from the input stream Stream without removing it nor modifying the stream's position or the end-of-file status and unifies it with Byte.

Note: in JavaScript, characters are represented using 16 bits, so, in browser, reading the next byte of a single character will make this predicate unify twice: the first time for the 8 least significant bits, and the second one for the next 8 bits. In the case of Node.js, the bits used to represent a character will depend on the file encoding.

Implementation