Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reminder - \r\n or \n\r?

I just can't remember those. So, what is the right way to properly terminate old fashioned ASCII lines?

like image 867
Daniel Mošmondor Avatar asked Jun 30 '11 19:06

Daniel Mošmondor


People also ask

Is it \n \r or \r \n?

\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.

What is the use of r n?

\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.

What is r n in HTML?

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.

Which character is used in Linux Unix based operating systems to denote a new line?

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).


2 Answers

I'd use the word 'return' to remember, the r comes before the n.

like image 187
David Snabel-Caunt Avatar answered Oct 06 '22 06:10

David Snabel-Caunt


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.

like image 38
BrunoLM Avatar answered Oct 06 '22 07:10

BrunoLM