Re: stringWithContentsOfURL: usedEncoding: error:
Re: stringWithContentsOfURL: usedEncoding: error:
- Subject: Re: stringWithContentsOfURL: usedEncoding: error:
- From: Adam Leonard <email@hidden>
- Date: Mon, 5 Jun 2006 20:47:18 -0700
I think you are a bit confused (or maybe I am). The usingEncoding
parameter does not tell you what encoding it used when reading it;
you must specify what encoding it should use. For a list of
encodings, see: <http://developer.apple.com/documentation/Cocoa/
Reference/Foundation/Classes/NSString_Class/Reference/
Reference.html#//apple_ref/doc/uid/20000154-35474>
I don't know what kind of files you are reading, but it is *usually*
safe to use NSUTF8StringEncoding
So I believe the correct code would be:
NSError *error;
NSString *test = [NSString stringWithContentsOfURL:[URLsToOpen
objectAtIndex:0]
usedEncoding:NSUTF8StringEncoding
error:&error];
Adam
On Jun 5, 2006, at 8:15 PM, Greg Stark wrote:
I caught the error after I posted to the list (I copied the example
from an outdated version of my source and have corrected it
below). With the correction, I get the same error: The file could
not be opened using the specified text encoding.
-Greg
On Jun 5, 2006, at 8:30 PM, Andy Lee wrote:
On Jun 5, 2006, at 10:11 PM, Greg Stark wrote:
NSStringEncoding enc;
NSError *error;
NSString *test = [NSString stringWithContentsOfURL:[URLsToOpen
objectAtIndex:0]
usedEncoding:&enc
error:&error];
NSStringEncoding isn't an object, it's just a typedef for
unsigned. Change
NSStringEncoding *enc;
to
NSStringEncoding enc;
--Andy
_______________________________________________
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
_______________________________________________
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
_______________________________________________
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