Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top