W3C home > Mailing lists > Public > whatwg@whatwg.org > June 2007

[whatwg] CR "entities" and LFCR

From: Michel Fortin <michel.fortin@michelf.com>
Date: Thu, 07 Jun 2007 21:18:58 -0400
Message-ID: <1901D98C-09D6-428D-88AE-CECBE80FB187@michelf.com>
Le 2007-06-07 ? 17:12, Michael A. Puls II a ?crit :

> Not sure if it'll help, but whenever I do newline normalization to  
> LF, I:
>
> Convert all CR + LF pairs to LF.
> Then, I convert any CRs left over to LF.
>
> Examples:
>
> LF + CR + LF + CR -> LF + LF + LF.
>
> CR + CR + LF -> LF + LF.

I think that's the standard way of doing it. Quoting Markdown source  
code, and some Perl code found on Wikipedia [1]:

     s/(\r\n|\n|\r)/\n/g

it does exactly that.

  [1]: http://en.wikipedia.org/wiki/Newline#Conversion_utilities

Windows use CR+LF, UNIX uses LF, legacy Mac applications still use  
CR; but I'm not aware of any system using LF+CR (and there is none on  
Wikipedia) and I don't think it's useful to give a meaning to it.


Michel Fortin
michel.fortin at michelf.com
http://www.michelf.com/
Received on Thursday, 7 June 2007 18:18:58 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:56 UTC