EntropySink
Technical & Scientific => Software => Topic started by: Micko on April 28, 2005, 06:03:40 PM
-
When you open file stdio.h (in attachment) you'll se (at least I see) that is very hard to read wth some weird symbols etc. I made following steps:
Select All -> Copy and Past to MS Word(here's becoming OK) ->Select all -> Copy and Paste to new file stdio1.h.
Now stdio1.h is like any other normal text file. Now I assume this is because of different file system (maybe I'm not using appropriate expressino) in Linux and Windows. Is this correct?
Why the look is different? I read something about Linux file formatting, but I was hoping someone here will explain it to me.
Thanks
- Micko
-
Linux uses one character for new lines "\n" (line feed). MS uses two characters for new lines "\r\n" (carriage return and line feed)
So MS has a problem with it because it expects both characters but only gets one
-
That is why stdio1.h is a little bigger.
So basically when windows file manager (or what?) find only \n it replace it with some strage marklike a little rectangle. OK
I use win xp and when I use something like this in C:
fprintf(fp, "Test\n");
Windows will write Test\r\n in file. Am I right ?
-
wouldn't it be
\n = \f\r
-
Now, I lost you. What is \f ?
-
No idea.
Stick to what Mike's said as that's the way it is.
Download SciTE (http://www.scintilla.org/SciTE.html) - it can display and convert between linux and window line break formats, as well as being a very good text/code editor that works on both operating systems so you can use it to view any text file (including that stdio.h) as a 'normal' text file regardless of its line break characteristics.
-
No idea.
Stick to what Mike's said as that's the way it is.
Download SciTE (http://www.scintilla.org/SciTE.html) - it can display and convert between linux and window line break formats, as well as being a very good text/code editor that works on both operating systems so you can use it to view any text file (including that stdio.h) as a 'normal' text file regardless of its line break characteristics.
/f is a form-feed character... used in old-school printing. to push the rest of the page out of the printer after you were done printing on it.
-
Shouldn't it be a line feed and a carriage return, though?
-
Shouldn't it be a line feed and a carriage return, though?
did it really matter back in the day? MS just chose an order and went with it :D
-
Thanks guys
-
It's been a while since I've actually looked so I can't remember if its 13 10 or 10 13. I know its \r\n when doing windows stuff.
I do think my typewriters did it newline carriage return though.
-
did it really matter back in the day? MS just chose an order and went with it :D
I didn't mean the order was important (it's not). I meant that it was important that it was a line feed instead of a form feed, unless you want one line per page.
-
I didn't mean the order was important (it's not). I meant that it was important that it was a line feed instead of a form feed, unless you want one line per page.
well, yeah... I think \n kinda-sorta takes the place of a linefeed... maybe? :dunno:
-
We're going in circles :(
All I'm saying is that sandman's response of \f\r is going to be wrong; it should be \l\r or \r\l.
-
We're going in circles :(
All I'm saying is that sandman's response of \f\r is going to be wrong; it should be \l\r or \r\l.
oh, well I kinda figured that was a given :(
-
OK, I'm going away now because I'm confusing everyone.
-
Well here's what I found:
Q:
What is the difference between \n and \r\n ? Should I be concerned about the differences ?
What types of characters indicate a new line ?
A:
Background
There are a few characters which can indicate a new line. The usual ones are these two:
"\n" or 0x0A (10 in decimal)
This character is called "Line Feed" (LF).
"\r" or 0x0D (13 in decimal)
This one is called "Carriage return" (CR)
Different Operating Systems handle newlines in a different way. Here is a short list of the most common ones:
DOS and Windows
They expect a newline to be the combination of two characters, namely "\r\n" (or 13 followed by 10).
Unix (and hence Linux as well)
Unix uses a single "\n" to indicate a new line.
Mac
Macs use a single "\r".
This difference gives rise to a number of problems. For example, a file created under Unix (so with newlines as a single LF) will not open correctly under Window's Notepad. Any Windows program that expects newlines to be CRLF will not work correctly with these files.
-
Off topic/ Hey Micko, nice to have ya aboard! /Off topic