Jan 17, 2015 at 1:54am Jan 17, 2015 at 1:54am UTC
I thought \r\n and \n\r would do the same in Windows but I am wrong.
Here is what I misunderstood:
\r\n:
First: \r: Carriage Return
Second: \n: New Line
\n\r:
First: \n: New Line
Second: \r: Carriage Return
So, the results should be the same. However, I tested and they aren't.
Could you explain why?
Jan 17, 2015 at 5:33am Jan 17, 2015 at 5:33am UTC
It is a bit confusing.
\r will move cursor to the beginning of a line.
\n will make a new line.
So, in my thinking \r\n and \n\r are the same.
For example:
Where: ++ present cursor position
--------------------------------------------++----------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Now with \r\n:
First: \r
++------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Then: \n (and we get \r\n)
----------------------------------------------------------------------------------------------------------------
++------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Now with \n\r:
First: \n
---------------------------------------------------------------------------------------------------------------
---------------------------------------------++---------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Then: \r (and we get \n\r)
----------------------------------------------------------------------------------------------------------------
++------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
As you can see, the results are the same.
What is wrong here?
Last edited on Jan 17, 2015 at 5:33am Jan 17, 2015 at 5:33am UTC