Difference between '\n' and '\r\n'
- by sukhbir
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.