Re: stringWithContentsOfURL: usedEncoding: error:
Re: stringWithContentsOfURL: usedEncoding: error:
- Subject: Re: stringWithContentsOfURL: usedEncoding: error:
- From: Greg Stark <email@hidden>
- Date: Mon, 5 Jun 2006 22:45:28 -0600
Thanks, Adam. It sounds like I may have to rethink this. I can't
afford to be guessing encodings because of the data corruption
issues. Unfortunately, I don't the the encodings ahead of time.
-Greg
On Jun 5, 2006, at 10:16 PM, Adam R. Maxwell wrote:
On Jun 5, 2006, at 21:03, Greg Stark wrote:
Supposedly the usedEncoding version of the method tries to
determine the encoding for you (at least according to the Strings
Programming Guide for Cocoa). Apple's suggestion for reading data
with unknown encoding is to try this method first. Also, I'd
rather not specify the encoding if I don't have to because it will
give me a little more flexibility later. I'm just not having much
luck with it and am beginning to think it is broken.
It's not broken, but it's definitely of limited utility; I think it
tries Unicode, then defaultCStringEncoding (but I can't find this
documented at the moment). For read-only data, I usually try
stringWithContentsOfURL; if it returns nil, I try UTF-8; it that
returns nil, I use ISO Latin 1, which always returns something
(even if it's wrong). If you're going to read/modify and write the
file, though, you'd better use the correct encoding to avoid
corrupting data.
Adam
_______________________________________________
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