1. Re[2]: reading a file

> Hi,

> Well, it depends which environment are you using (or text was 
> built). If your platform is Windows (or DOS) then you have to look 
> for a CR+LF (0Dh+0Ah). If you're on Linux (Unix) then it's only LF 
> (0Ah). In other hand we have Macintosh that uses only CR (0Dh) at 
> line end. You should test to see what you're finding before choose 
> the right algorithm.

> Cheers!

> -- Euler

If the file is being read in using text mode ("r" instead of "rb"
passed to open) then all newlines will be converted to 10.

Thomas Parslow (PatRat) ICQ #:26359483
Rat Software
http://www.rat-software.com/
Please leave quoted text in place when replying

new topic     » topic index » view message » categorize

2. Re: Re[2]: reading a file

On 3 Jan 2002, at 23:22, Thomas Parslow (PatRat) wrote:

> 
> > Hi,
> 
> > Well, it depends which environment are you using (or text was 
> > built). If your platform is Windows (or DOS) then you have to look 
> > for a CR+LF (0Dh+0Ah). If you're on Linux (Unix) then it's only LF 
> > (0Ah). In other hand we have Macintosh that uses only CR (0Dh) at 
> > line end. You should test to see what you're finding before choose 
> > the right algorithm.
> 
> > Cheers!
> 
> > -- Euler
> 
> If the file is being read in using text mode ("r" instead of "rb"
> passed to open) then all newlines will be converted to 10.

What about the last line in a text file that may not end in a CR or a NL ?

Kat

new topic     » goto parent     » topic index » view message » categorize

3. Re: Re[2]: reading a file

Kat wrote:

> What about the last line in a text file that may
> not end in a CR or a NL ?

Good point. Some editors (like SciTE) don't put a CR/LF on the last line.

I got bitten by this bug a couple weeks ago with an interpreter that I had
written. The user was reporting odd errors that I couldn't duplicate, until
it occured to me the last line of code wasn't being parsed.

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu