Peeking at the next character without consuming it is useful when the interpretation of “this character” depends on what the next one is.
peek_byte([
Stream,]
N)
unifies N with the next unconsumed
byte from the current or given input stream, which must be binary.
peek_code([
Stream,]
N)
unifies N with the next unconsumed
character code from the current or given input stream, which must be text.
peek_char([
Stream,]
A)
unifies A with the next unconsumed
character atom from the current or given input stream, which must be text.