W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2009

Re: [EventSource] feedback from implementors

From: Michael A. Puls II <shadow2531@gmail.com>
Date: Sat, 19 Sep 2009 12:43:42 -0400
To: "Per-Erik Brodin" <per-erik.brodin@ericsson.com>, public-webapps@w3.org
Message-ID: <op.u0ije4q51ejg13@sandra-svwliu01>
On Fri, 18 Sep 2009 11:37:24 -0400, Per-Erik Brodin  
<per-erik.brodin@ericsson.com> wrote:

> When parsing an event stream, allowing carriage return, carriage return
> line feed, and line feed to denote line endings introduces unnecessary
> ambiguity into the spec. For example, the sequence "\r\r\n\n" could be
> interpreted as three or four line endings.

That would always be 3 lines: a mac, a windows and a nix. "\n\r\n\r" would  
be the reverse order, but still 3.

Universal newline normalization for input with mixed newline formats:

// normalize newlines to \n
.replace(/\r\n|\r/g, "\n");

// normalize newlines to \r\n
.replace(/\r\n|r|\n/g, "\r\n");

// normalize newlines to \r
.replace(/\r\n|\n/g, "\r");

Ideally, I think it's often best to do the first to normalize to \n for  
processing (like if you need to know line count) and then normalize to a  
different format *if needed* afterwards.

IMO

-- 
Michael
Received on Saturday, 19 September 2009 16:44:21 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:33 GMT