The Great Newline Schism

There’s a common and accepted way to normalize newlines (using js regex for examples):

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

The first method is used for server-sent events (not regex, but the normalizing of \r\n and \r to \n via parsing).

The second method is used in HTML5 for textarea value getters/setters. Opera does this already. However, Webkit currently uses the first method and Gecko and IE do different things depending on the situation.

You can use __lookupGetter/Setter__ and __defineGetter/Setter__ or Object.getOwnPropertyDescriptor and Object.defineProperty to patch a textarea’s ‘value’ getter and setter to work around the differences in newline normalization.

Newlines being right for a textarea’s value is important because it affects the value’s length, which many sites (like Twitter) use as character counters to enforce limits.

I absolutely hate the newline deal though. I wish we could get rid of it and just use only \n everywhere.

As for a Unicode newline, I once tried to switch to using it (just to be
Unicode-proper and all that), but couldn’t find anything that handled it
display-wise.