Difference between '\n' and '\r\n'
Posted
by
sukhbir
on Programmers
See other posts from Programmers
or by sukhbir
Published on 2010-12-22T11:38:40Z
Indexed on
2011/02/20
15:32 UTC
Read the original article
Hit count: 174
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.
© Programmers or respective owner