For example on my PC it looks like it will use "\r\n"? Could it ever be something different than that?
Asked
Active
Viewed 983 times
0
-
Are you asking this? http://stackoverflow.com/questions/6324167/do-browsers-send-r-n-or-n-or-does-it-depend-on-the-browser – thirtydot Jun 18 '11 at 23:02
-
@thirtydot It seems so and still no good/definitive answer. the regexp is still a rn|n||r combo. – Captain Giraffe Jun 18 '11 at 23:14
-
@thirtydot - actually, I don't think it is the same question. The question you link to is about the line ending encoding over the wire. This link http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1 states that if the data is sent as application/x-www-form-urlencoded or multipart/form-data, the line ending must be CR,LF. This question is about behaviour inside a textarea. From some recent experience I got the impression that some browsers weren't fussy, and would simultaneously treat CR,LF and bare LF's (possibly bare CRs too) as line endings. – Alohci Jun 19 '11 at 00:18
-
@Alohci: It looks like you're right. I wasn't sure, so *I* didn't cast a close vote. – thirtydot Jun 19 '11 at 00:29
2 Answers
1
Historically it's \r\n
on Windows, \r
on Mac and \n
on *nix. If you take these into consideration you 're golden.
Also: I don't know if this is relevant in your case, but typically many programming languages define a string constant which represents the "native" form of end-of-line for the system they are running on (e.g. PHP_EOL
in PHP, Environtment.Newline
in C#, etc).

Jon
- 428,835
- 81
- 738
- 806
1
It depends upon the OS I guess, the same old story:
\n
for unix like (and I think OS X too)\r\n
for windows like\r
old Apple OSes

Jack
- 131,802
- 30
- 241
- 343
-
That's only for how the OS (or more accurately, the default runtime libraries). The HTML spec specifies what a line ending should be (\r\n). – Chris J Jun 18 '11 at 23:15