Re: Reading one line at a time using NSFileHandle

2009-03-27 Thread Andrew Farmer
On 26 Mar 09, at 13:27, Erg Consultant wrote: I read the CocoaBuilder thread to no avail. fgets won't work in my case because my text file contains special characters which fgets mangles. fgets is encoding-agnostic. You're probably going about the char* -> NSString conversion wrong - how a

Re: Reading one line at a time using NSFileHandle

2009-03-26 Thread Michael Ash
On Thu, Mar 26, 2009 at 5:48 PM, Erg Consultant wrote: > Tried that approach too. Problem with using NSString is that when it comes > time to write the line out to the new file, I need an NSData and to create > one, I have to use NSString's getBytes or getCharacters. Those only return > unicode

Re: Reading one line at a time using NSFileHandle

2009-03-26 Thread Ken Thomases
On Mar 26, 2009, at 4:48 PM, Erg Consultant wrote: Problem with using NSString is that when it comes time to write the line out to the new file, I need an NSData and to create one, I have to use NSString's getBytes or getCharacters. No, you should use -[NSString dataUsingEncoding:]. If you

Re: Reading one line at a time using NSFileHandle

2009-03-26 Thread Erg Consultant
om: Jean-Daniel Dupas To: Erg Consultant Cc: cocoa-dev@lists.apple.com Sent: Thursday, March 26, 2009 2:05:55 PM Subject: Re: Reading one line at a time using NSFileHandle If this is a small file, just create an NSString and iterate over lines. Here is a simple snippet that count number of lines i

Re: Reading one line at a time using NSFileHandle

2009-03-26 Thread Jean-Daniel Dupas
after processing each one. One would think Cocoa would have something like fgets but that works with any encoding. Erg From: Matt Neuburg To: Erg Consultant Cc: cocoa-dev@lists.apple.com Sent: Thursday, March 26, 2009 7:24:29 AM Subject: Re: Read

Re: Reading one line at a time using NSFileHandle

2009-03-26 Thread Erg Consultant
g To: Erg Consultant Cc: cocoa-dev@lists.apple.com Sent: Thursday, March 26, 2009 7:24:29 AM Subject: Re: Reading one line at a time using NSFileHandle On Wed, 25 Mar 2009 19:36:01 -0700 (PDT), Erg Consultant said: >Is there a way to read one line of a text file at a time using NSFileHandle (th

Re: Reading one line at a time using NSFileHandle

2009-03-26 Thread Michael Ash
On Wed, Mar 25, 2009 at 11:44 PM, Jeff Laing wrote: >>> Is there a way to read one line of a text file at a time >>> using NSFileHandle (the way fgets does)? >> >> This code illustrates how you might approach >> filtering lines of data obtained through an NSFileHandle. > > I've come across this pr

Re: Reading one line at a time using NSFileHandle

2009-03-26 Thread Matt Neuburg
On Wed, 25 Mar 2009 19:36:01 -0700 (PDT), Erg Consultant said: >Is there a way to read one line of a text file at a time using NSFileHandle (the way fgets does)? Is it my imagination or did we not just have a big thread about this...?

RE: Reading one line at a time using NSFileHandle

2009-03-25 Thread Jeff Laing
>> Is there a way to read one line of a text file at a time >> using NSFileHandle (the way fgets does)? > > This code illustrates how you might approach > filtering lines of data obtained through an NSFileHandle. I've come across this problem as well - its fine to say "read it all into memory,

Re: Reading one line at a time using NSFileHandle

2009-03-25 Thread Joel Norvell
> Is there a way to read one line of a text file at a time > using NSFileHandle (the way fgets does)? This code illustrates how you might approach filtering lines of data obtained through an NSFileHandle. NSFileHandle* yourFileHandle; NSString* input; NSArray* lines;