"\n" and "\r"

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
alex
Posts: 100
Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia

"\n" and "\r"

Post by alex »

I use WindowsXP and have simple program in file test.lsp:

Code: Select all

(print "\n\n\n\n\n")
(exit)
I run cmd.exe and execute command

Code: Select all

newlisp test.lsp > test.txt
Then I see, that size of file test.txt is 10 and it contain
"\n\r\n\r\n\r\n\r\n\r"
It is normal?

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

Post by Lutz »

Yes, this is normal: it will translate UNIX line terminators "\n" to "\r\n" line terminators on the MS-Windows platform.

Keep this in mind when porting newLISP scripst to UNIX, if they run as shell scripts with:

#!/usr/bin/newlisp

in the first line, they will fail if they have Windows line terminators, and have to be translated first (i.e. using dos2unix)

Lutz

alex
Posts: 100
Joined: Thu Mar 10, 2005 2:27 pm
Location: Russia

Post by alex »

I can't express my mind in english enough,
but it is very interesting information not only for me :-)

Locked