Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows notepad not supporting newline character '\n'

From my iPhone application I'm outputting data from text to a file. When opened with windows notepad, the data is all on one line and where there should be a new line a block character is present (showing that it's an unrecognized character or something). When opened with windows wordpad, it displays just fine.
Would there be something wrong in my code? I'm simply output '\n' when i want a new line.

enter image description here

NOTE : It's working fine with other editors like textedit, MS Word on mac as well as on windows.

like image 980
Ankur Avatar asked Jan 06 '12 08:01

Ankur


People also ask

How do you show newline characters on Notepad?

Open any text file and click on the pilcrow (¶) button. Notepad++ will show all of the characters with newline characters in either the CR and LF format. If it is a Windows EOL encoded file, the newline characters of CR LF will appear (\r\n). If the file is UNIX or Mac EOL encoded, then it will only show LF (\n).

How do you replace N with a new line?

So: Press CTRL-h and the Replace dialog will open. Type \r\n in "Find what" and \\r\\n in "Replace with". Then select search mode Extended (\r, \n, \t, \x..., \0) and click "Replace All".

Is New Line \n or n?

For example, in Linux a new line is denoted by “\n”, also called a Line Feed. In Windows, a new line is denoted using “\r\n”, sometimes called a Carriage Return and Line Feed, or CRLF.

How do you replace a character with a new line in Notepad++?

In the “Find What” box, enter “\n”. In the Replace with box, type the character that you want to replace it with. Make sure “Extended” is selected and click “Replace All,” and your list will go back to being separated by a standard character, such as a comma or pipe.


1 Answers

Windows default is to use \r\n as end-of-line marker. Notepad only recognises that, other text editors may know about other line-end styles and render correctly.

EDIT
As VonC answers Notepad had an update (in 2018) where it now can recognize non-Windows end-of-line sequences.

like image 71
Hans Kesting Avatar answered Oct 14 '22 13:10

Hans Kesting