Windows notepad not supporting newline character '\n'

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.


This is because \n does not represent a full line break in Windows. Using \n is "the Unix" way of doing line breaks.

On Windows, there are text-editors like Notepad++ which handle both, but Notepad is really dumb in that respect.

I suggest you create a setting in your iPhone application where the user can choose between Windows and Unix line endings - then it's his responsibility :-)


I'm simply output '\n' when i want a new line.

And starting May 2018 (6 years later), you will get a newline!

See "Introducing extended line endings support in Notepad" by Michel Lopez (and his tweet)

For many years, Windows Notepad only supported text documents containing Windows End of Line (EOL) characters - Carriage Return (CR) & Line Feed (LF). This means that Notepad was unable to correctly display the contents of text files created in Unix, Linux and macOS.

Today, we’re excited to announce that we have fixed this issue!

Starting with the current Windows 10 Insider build, Notepad will support Unix/Linux line endings (LF), Macintosh line endings (CR), and Windows Line endings (CRLF) as usual.

New files created within Notepad will use Windows line ending (CRLF) by default, but it will now be possible to view, edit, and print existing files, correctly maintaining the file’s current line ending format.

Also note that the status bar indicates the detected EOL format of the currently open file.

See an .bashrc finally displayed correctly!

https://msdnshared.blob.core.windows.net/media/2018/05/Notepad-after.png