Page 1 of 1

write-line outputs CRCRLF on my XP box

Posted: Fri Jun 01, 2007 12:03 am
by John_Small
Hi,

I'm using version 9.1.1 on windows XP.

(write-line "")

and

(println "")

both output a three character sequence

CRCRLF

instead of just

CRLF

Is there something I'm doing wrong?

Posted: Fri Jun 01, 2007 12:26 am
by Lutz
The extra CR is added by Windows in piping situations, newLISP itself only outputs CR-LF (on UNIX only LF). Try this to verify:

Code: Select all

> (device (open "test.txt" "w"))
3
> (println "hello")
"hello"
> (close (device))
true
> (set 's (read-file "test.txt"))
"hello\r\n"
>
You also can verify this using write-line to a file or to a string buffer and will get the same result.

I found out about this years ago when doing CGI work on Windows. If you pipe your STDOUT to a file, Windows will add that extra CR before all LF. The only way around it is stripping it off with a (replace {\r\r\n} buffer {\r\n}).

Lutz

Posted: Fri Jun 01, 2007 1:47 am
by rickyboy
Hey John_Small,

Are you the same John Small who used to be user jsmall here and who wrote the newLISP tutorial? If so, how come the new username (John_Small)?

Curious,
--Rick