See for example:
CL-USER> (write "\\" :escape nil)
\
"\\"
Here above, the first backslash is your string, printed without escaping backslashes. The returned value is the string, printed by the REPL with the standard io syntax (http://clhs.lisp.se/Body/m_w_std_.htm), which escapes strings.
So, your string contains a single backslash, but is printed in such a way that it can be read back, hence the need to escape the backslash in the output string.
Note also that calling format
with NIL and a single string returns the same string.
You can inspect your strings, for example by mapping each character to its name:
(loop
for input in '("\ "
"\\ "
"\\\ ")
collect (list :input input
:characters (map 'list #'char-name input)))
This gives:
((:INPUT " " :CHARACTERS ("Space"))
(:INPUT "\\ " :CHARACTERS ("REVERSE_SOLIDUS" "Space"))
(:INPUT "\\ " :CHARACTERS ("REVERSE_SOLIDUS" "Space")))
Or, simply use inspect
:
CL-USER> (inspect "\\hline")
The object is a VECTOR of length 6.
0. #\\
1. #\h
2. #\l
3. #\i
4. #\n
5. #\e