In JavaScript this was a cross-browser compatibility issue, so both were used, but there are numerous instances in different languages where I see both printed out together as \r\n. Is this still the generally excepted norm that you should just always use both, or is there ever a time where languages understand both and you end up with a break and a return?
views:
1196answers:
2
+7
A:
The CRLF pair is the expected end-of-line (EOL) marker on most internet protocols.
Here, Postel's "Robustness Principle" should apply. Be liberal in what you accept, but strict in what you send. So, be prepared to receive just a LF, but if you're sending data use whatever the relevant standards require.
Alnitak
2008-11-02 21:13:06
Robustness principle is the cause for HTML soup. Damn the principle! :-)
Vinko Vrsalovic
2008-11-02 21:17:48
you should also accept just CR, because some older systems used just CR.
Brad Gilbert
2008-11-02 22:10:33
No, you should be fairly strict in what you accept and very strict in what you emit. This cuts down on unexpected errors where something tries to guess what some possible ambiguity means instead of just rejecting it.
staticsan
2008-11-03 00:40:09
staticsan - 27 years worth of internet protocols disagree with you. See RFC793.
Alnitak
2008-11-03 08:14:43
+2
A:
This is not a language compatibility issue, but either a file issue or a protocol issue. File-wise: Unix uses \n as a carriage return, Windows uses \r\n and I think MacOS used (not sure about now) \r. Many 'cross platform' languages abstract this in a platform dependant variable. Protocol-wise: what the protocol specifies.
Vinko Vrsalovic
2008-11-02 21:16:01
The current Macintosh OS (OS X) is Unix, and uses newline ('\n') as the line separator.CP-M/MS-DOS/Windows use \r\n because early character-mode printers required one control char to move the print head to the left margin (\r) and one to advance the paper by one line (\n).
joel.neely
2008-11-04 04:19:27