[racket] CRLF vs LF & windows

From: Hendrik Boom (hendrik at topoi.pooq.com)
Date: Sun Oct 2 16:51:57 EDT 2011

On Sun, Oct 02, 2011 at 01:53:17AM +0200, Jos Koot wrote:
> In the past I have encountered some inconsistencies using DrRacket
> (DrScheme) programs producing files I could not read back because of the lf
> cq lfcr inconsitensy. Since a few months I have not noticed any difficulty.
> IIRC this was with checking equality of strings produced by DrRacket with
> those in the code itself. I'll keep you posted. Thanks for thinking about
> simple Window users like me.
> My Suggestion:
> Always read cr, lf and crlf as identical, both in code and read data.

No.  Always reac cr, lf, and crlf as valid representations for a new 
line.  They're still different characters, and may have to be treated as 
such sometimes, such as for reading in and writing out unchanged when 
potentially interacting with revision control systems.

> So
> "\n" should match cr, lf and crlf. This may have nasty consequenses for
> procedure string-length. Drop cr and lf and make it 'newline', crlf
> included.
> The best thing, of course, would be microsoft to adapt to more generally
> adopted conventions, but they probably can't because of backward
> compatibility.

It may be worth mentioning that here it was Microsoft that adopted the 
international standard, where cr and lf were both needed for a new line 
in the official ASCII code.  It was Unix that deviated from the 
standard.  There is now an official newline character, separate from CR 
and LF, and it's one of the control characters with the high bit set, 
and so it's mapped somewhere complicated in UTF-8.  I don't know what 
its bit-coding is, but it seems to be universally ignored.

> May be at the DrScheme level, we should ignore all control characters,
> except newline, encoded as cr, lf or crlf, (the last combination being
> counted as one single character, how nasty this may be)

In any case, the official newline character should probably be 
recognised as a newline, too, whatever it is.

> I'll inform you of my experiences with you latest adaptation in this
> respect.
> Thanks, Jos 
> -----Original Message-----
> From: users-bounces at racket-lang.org [mailto:users-bounces at racket-lang.org]
> On Behalf Of Robby Findler
> Sent: sábado, 01 de octubre de 2011 3:16
> To: Racket Users
> Subject: [racket] CRLF vs LF & windows
> I've pushed a change today in the way that DrRacket handles line
> endings under windows. If you are a regular windows user who has the
> energy to give the pre-release a try for your usual DrRacketeering for
> a week or month or so to share you feedback on this change, that'd be
> great.
> In old versions, DrRacket would open a file in any style and then save
> it using CRLF (under windows; it would always save regular LF files on
> other platforms). In the current pre-release, DrRacket checks to see
> if every line ends in CRLF in the file and, if so, it saves the file
> in CRLF (and puts a little warning in the bottom of the window that it
> is in this mode). Otherwise, it saves the file in LF mode. There is a
> preference to go back to the old behavior too.
> Feedback welcomed.
> Thanks,
> Robby
> _________________________________________________
>   For list-related administrative tasks:
>   http://lists.racket-lang.org/listinfo/users
> _________________________________________________
>   For list-related administrative tasks:
>   http://lists.racket-lang.org/listinfo/users

Posted on the users mailing list.