I just can\'t remember those. So, what is the right way to properly terminate old fashioned ASCII lines?
\r\n
for Windows will do just fine.
If you are using C# you should use Environment.NewLine, which accordingly to MSDN it is:
A string containing "\r\n" for non-Unix platforms, or a string containing "\n" for Unix platforms.
In any .NET langauge, Environment.NewLine
would be preferable.
Be careful with doing this manually.
In fact I would advise not doing this at all.
In reality we are talking about the line termination sequence LTS that is specific to platform.
If you open a file in text mode (ie not binary) then the streams will convert the "\n" into the correct LTS for your platform. Then convert the LTS back to "\n" when you read the file.
As a result if you print "\r\n" to a windows file you will get the sequence "\r\r\n" in the physical file (have a look with a hex editor).
Of course this is real pain when it comes to transferring files between platforms.
Now if you are writing to a network stream then I would do this manually (as most network protocols call this out specifically). But I would make sure the stream is not doing any interpretation (so binary mode were appropriate).
I'd use the word 'return' to remember, the r comes before the n.
The sequence is CR (Carriage Return) - LF (Line Feed). Remember dot matrix printers? Exactly. So - the correct order is \r \n