Possible Duplicate:
What is the difference between \r and \n?
I really would like to know what's the difference between \n
, \r
, \t
, chr(13)
, how they are used in a web application, in which OS, and so on.
For example, can you confirm that windows uses \n\r
for the newline, while of linux uses just \n
right? It would be interesting to know these things.
Thanks
These are character escape sequences in many languages (c, c++, java, javascript, .NET to name a few). They directly translate to the equivalent ASCII values (you posted this as chr(13)
which in one language would produce a character based on that ASCII value).
Their meanings are:
\n == chr(13) == carriage return
\r == chr(10) == line feed
\t == chr (9) == tab
These all come from control characters for printers, in turn coming from typewriters.
A carriage return brings the typewriter to the beginning of the line.
A line feed brings the typewriter to the next line.
A tab moves the typewriter to the next tab stop.
A combination of line feed and carriage return is needed to bring the typewriter to the start of the next line.
The differences between windows and unix stem from the different decisions on the different platforms on how to represent a new line. Unix went with carriage return (probably also to save space), Windows with both. Macs used to use linefeeds for the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With