[whatwg] CR "entities" and LFCR

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