On Wed, May 13, 2009 at 11:53 AM, Ryan Joseph
<thealchemistgu...@gmail.com> wrote:
> First question, why is the most obvious and best solution deprecated?
> NSString's initWithContentsOfFile:  accepts no encoding and appears it is
> getting the correct encoding in my tests.  Now they want us to use
> initWithContentsOfFile:encoding:error: and figure out the encoding
> ourselves? Sounds like now every person is going to be writing some
> utilities for sniffing encodings.
>
> I think I'm going to use initWithContentsOfFile despite Apple's wishes to do
> this myself but I did try the Carbon TEC manager and it appears to have
> created a organized list of encodings from the input bytes but it's totally
> wrong. The top choice was kTextEncodingJIS_X0208_90 followed by other Asian
> encodings for a file a plainly saved as UTF8 from TextEdit. I would say it
> was an error but it actually organized that list from the previous list of
> 200+ available encodings. Does that thing even work?

use -initWithContentsOfFile:usedEncoding:error: (introduced when
initWithContentsOfFile: was deprecated)

This way, it not only attempts to determine the encoding for you, but
tells you what encoding it successfully used, and rather than simply
returning nil on error, it gives you the error as well.

HTH

Dave.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to