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. A single \n does just fine on windows too, including the latest version of Notepad. I think modern editors will detect line endings, as different OS use different endings.
\n means new line. It means that the cursor must go to the next line. \r means carriage return. It means that the cursor should go back to the beginning of the line.
Windows uses \r\n characters to specify the start of the line, sometimes also called Carriage Return and Line Feed (CRLF). In this short article, we'll look at replacing all new line characters in a string with an HTML line-break ( <br> ) tag so that it can be displayed as a multi-line string.
The Line Feed (LF) character moves the cursor down to the next line without returning to the beginning of the line. This character is used as the new line character in Unix based systems (Linux, macOS X, Android, etc).
I'd use the word 'return' to remember, the r comes before the n.
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.
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