[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is "]" == "\]"?



> Well, I expected, if I read from a string-char-stream with
> read-char-sequence that I get a sequence of the characters from the
> input stream. And I expected the characters are the same as in the
> input-file.

This is exactly what you get.

> Nope! If I make a string-char-input-stream with the string above or a
> file containing the string, I dont't get what you said, but you get
> "[foo [ bar ] baz ]".

You must be calling READ on the same line twice, or something like that.
Maybe a sample log can convince you:

$ cat > andrich-file
[ foo \[ bar \] baz ]
$ cat andrich-file
[ foo \[ bar \] baz ]
$ clisp -q

> (setq line (with-open-file (f "andrich-file") (read-line f)))
"[ foo \\[ bar \\] baz ]"
> (length line)
21
> (count #\\ line)
2
> (setq s (make-string-input-stream line))
#<STRING-INPUT-STREAM>
> (setq l (make-list (length line)))
(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL
 NIL)
> (read-char-sequence l s)
21
> l
(#\[ #\Space #\f #\o #\o #\Space #\\ #\[ #\Space #\b #\a #\r #\Space #\\ #\] #\S
pace #\b #\a #\z #\Space #\])


                    Bruno Haible
                    haible@ma2s2.mathematik.uni-karlsruhe.de