Aiden
Aiden

Reputation: 460

IE 9 inserts line break as \r\n but IE 11 inserts line break as \n

I have a text area in my web application in which I write text with new lines in them

e.g.

abc
abc

When I save it using java into SQL server IE9 browser reads the text in text area as abc\r\nabc but when I save with IE11 it reads text area as abc\nabc

Why is it so? Is there a difference in new line rendering of these browsers?

Upvotes: 0

Views: 1727

Answers (1)

Stefan Steiger
Stefan Steiger

Reputation: 82136

IE9 uses Windows newlines ("\r\n"), while IE11 uses POSIX newlines ("\n").
You need to normalize these anyway, because Linux/Unix systems always use \n.

Usually, you can assume that \r does not disturb, so you can normalize to \r\n, for which a line should display on a new line in all browsers.

As a sidenote, if you'd save Linux shell scripts, then this would matter, because it would interprete \r as part of the shell interpreter's name.

Upvotes: 3

Related Questions