Re: How to detect string encoding before reading a file in NSString?
Re: How to detect string encoding before reading a file in NSString?
- Subject: Re: How to detect string encoding before reading a file in NSString?
- From: Nick Zitzmann <email@hidden>
- Date: Tue, 26 Apr 2011 12:43:10 -0600
On Apr 26, 2011, at 12:13 PM, Laurent Daudelin wrote:
> I've found different ways to do that (some pure Cocoa, some using Carbon) but I was wondering about the wisdom of this list as to what is the best way to detect the encoding of a file before passing it to NSString initWithContentsOfFile:encoding:error:?
TextEdit's encoding guesser just uses the built-in NSAttributedString method -initWithURL:options:documentAttributes:error:, which will guess the file's encoding when opening it. But it has been mentioned that heuristics are not infallible, and this method's heuristics are no exception. It does a good job overall, but I've found that it usually misinterprets UTF-8 format text.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden