I just can\'t remember those. So, what is the right way to properly terminate old fashioned ASCII lines?
\r\n
Odd to say I remember it because it is the opposite of the typewriter I used.
Well if it was normal I had no need to remember it... :-)
*Image from Wikipedia
In the typewriter when you finish to digit the line you use the carriage return lever, that before makes roll the drum, the newline, and after allow you to manually operate the carriage return.
You can listen from this record from freesound.org the sound of the paper feeding in the beginning, and at around -1:03 seconds from the end, after the bell warning for the end of the line sound of the drum that rolls and after the one of the carriage return.
if you are using C#, why not using Environment.NewLine
? (i assume you use some file writer objects... just pass it the Environment.NewLine
and it will handle the right terminators.
From Wikipedia (you can read which is correct for your OS at that article):
Systems based on ASCII or a compatible character set use either LF (Line feed, '\n', 0x0A, 10 in decimal) or CR (Carriage return, '\r', 0x0D, 13 in decimal) individually, or CR followed by LF (CR+LF, '\r\n', 0x0D0A).
New line depends on your OS:
DOS & Windows: \r\n 0D0A (hex), 13,10 (decimal)
Unix & Mac OS X: \n, 0A, 10
Macintosh (OS 9): \r, 0D, 13
More details here: https://ccrma.stanford.edu/~craig/utility/flip/
When in doubt, use any freeware hex viewer/editor to see how a file encodes its new line.
For me, I use following guide to help me remember: 0D0A = \r\n = CR,LF = carriage return, line feed