Re: Objective-C BufferedReader
Re: Objective-C BufferedReader
- Subject: Re: Objective-C BufferedReader
- From: Will Mason <email@hidden>
- Date: Sat, 12 Feb 2005 18:21:34 -0800 (PST)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Actually, you only want stringWithUTF8String if you know that the file
is encoded as UTF-8. Otherwise, you want initWithBytes:length:encoding:
passing the encoding of the file for the last argument. Also, the
string returned by fgetln() is not null-terminated, so you can't use
stringWithUTF8String, anyway.
Will
--- John Stiles <email@hidden> wrote:
> stringWithCString is deprecated. You want stringWithUTF8String.
>
> On Feb 12, 2005, at 4:01 PM, Hamish Allan wrote:
>
> > Jason,
> >
> > Thanks for your speedy response. You're quite right that I meant to
>
> > put the fgets() in the loop, but my main problem turned out to be
> that
> > I was trying to test my code from the XCode console, which doesn't
>
> > accept more than 1024 characters, and that was what my
> BUFFER_LENGTH
> > was set to be :(
> >
> > Thanks! I never knew about fgetln(), and my code is now much
> shorter:
> >
> > - (NSString *)readLineFromStdin
> > {
> > size_t length;
> > char *chars = fgetln(stdin, &length);
> > return [NSString stringWithCString:chars length:(unsigned
> int)length];
> > }
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden