Escape sequences are inserted into the ouput as appropriate:
?- writeq('hel\nlo'). 'hel\nlo' true.
?- write('hel\nlo'). hel lo true.
Same as for strings, as expected:
?- write("hel\nlo"). hel lo true.
?- writeq("hel\nlo"). "hel\nlo" true.
Note that the
\n is translated by the Prolog reader into a single newline, it is NOT in the atom or string as such
?- A='hel\nlo',atom_length(A,L). A = 'hel\nlo', L = 6.