Yes yes, I am aware that '\n'
writes a newline in UNIX while for Windows there is the two character sequence: '\r\n'
. All this is very nice in theory, but my question is why? Why the carriage return character is extra in Windows? If UNIX can do it in \n
why does it take Windows two characters to do this?
I am reading David Beazley's Python book and he says:
For example, on Windows, writing the character '\n' actually outputs the two- character sequence '\r\n' (and when reading the file back, '\r\n' is translated back into a single '\n' character).
Why the extra effort?
I will be honest. I have known the difference for a long time but have never bothered to ask WHY. I hope that is answered today.
Thanks for your time.
\r\n
. It's also used by most text-based internet protocols (e.g. SMTP, HTTP, etc) for largely the same reason as Windows (ie history).System.out.printf()
orString.format()
) make sure you use%n
as your CRLF for OS compatibility purposes.\n
is deprecated.\n\r
several times. (I think it was something from NetWare.)