write-line outputs CRCRLF on my XP box

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
John_Small
Posts: 12
Joined: Thu May 10, 2007 9:09 pm

write-line outputs CRCRLF on my XP box

Post 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?

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post 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

rickyboy
Posts: 607
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Post 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
(λx. x x) (λx. x x)

Locked