Results 1 to 9 of 9
Hi,
I've been developing in PHP for a few years and I've noticed that a file that I created in vi editor using SSH on my linux server, when viewed ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 01-12-2008 #1Just Joined!
- Join Date
- Jan 2008
- Posts
- 21
New line character in windows and linux
Hi,
I've been developing in PHP for a few years and I've noticed that a file that I created in vi editor using SSH on my linux server, when viewed with notepad wasnt displaying properly. I noticed the same thing happen in a few other instances. Why is that?
What is the ascii number of a new line character in windows and linux?
Raja Sekharan
- 01-12-2008 #2Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
UNIX/Linux uses a newline character (\n, decimal 12) as a line terminator, Windoze uses carriage-return newline pairs (\r\n decimal 15, 12). You can use dos2unix and unix2dos to switch formats, but it's Windows that is out of step by using 2 characters as a line terminator instead of a more sensible single one, and since UNIX specified that character back in the early 70s, it can only be bloody-mindedness on Bill Gates' part that he deliberately chose to be incompatible.
- 01-12-2008 #3Just Joined!
- Join Date
- Jan 2008
- Posts
- 21
Ok but, in notepad, atleast the '\n' should be rendered right? All i saw as a continuous wall of code with "box"y characters where the line breaks were supposed to be. When you try to delete those characters, notepad seems to misbehave.
- 01-12-2008 #4
Different editors handle this differently, with some seemingly able
to handle both formats. There are lots of free replacements for
notepad, and some of them may be better with line feeds.
For the historical record, the CR/LF two character line ending is
the original ascii standard that predates both unix and microsoft,
and it was unix that departed from the standard.
- 01-12-2008 #5Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
- 01-13-2008 #6Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
D'oh, old habits die hard!
:%s/decimal/octal/g
- 01-13-2008 #7Linux Engineer
- Join Date
- Nov 2004
- Location
- Ft. Polk, LA
- Posts
- 796
You can use wordpad on windows, it handles \n properly.
- 05-11-2008 #8
I'm using a single todo file synchronized within Ubuntu Gutsy and Windows xp.
gedit uses LF line ending as other linux editors does, and I'm using Notepad2 instead of Notepad to handle LF instead of CR line endings.
Notepad2 has an option to choose line endings character.
Notepad++ is another choice.
- 05-13-2008 #9Just Joined!
- Join Date
- May 2008
- Location
- Åsnorrbodarna
- Posts
- 8
If you're using vim (which I believe is the case in most Linux distros) you can also do :set ff=dos (or :set fileformat=dos) to make it use CR+LF instead of just LF for line breaks. You can add the setting to your .vimrc file if you want it for all files (or certain file types).


Reply With Quote

