Sometimes it desirable to print (write) a term with the character escape sequences intact (syntactically) as opposed to them being performed (semantically), e.g. print
\n instead of performing a new line.
write_canonical/1 is the sword of choice in such situations.
?- write("string\n\n"). string true. ?- write_canonical("string\n\n"). "string\n\n" true.
Since format/2,3 is often used for displaying output, write_canonical/1 is an available option using the special sequence
Give the next argument to write_canonical/1.
?- format('~w',["string\n\n"]). string true. ?- format('~k',["string\n\n"]). "string\n\n" true.