[whatwg] CR "entities" and LFCR
Michel Fortin
michel.fortin at michelf.com
Thu Jun 7 18:18:58 PDT 2007
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/
More information about the whatwg
mailing list