Re: How to convert UInt8 array to NSString
Re: How to convert UInt8 array to NSString
- Subject: Re: How to convert UInt8 array to NSString
- From: "Joe Goh" <email@hidden>
- Date: Fri, 9 May 2008 03:26:01 +0800
Hi Marc,
Wish this thread existed 2 years ago. :-) But I digress..
You may also consider using the alternative approach of getting the
user to select the most readable encoding (after you've tried
automatically detecting it) and floating the most appropriate/most
frequently used encodings on top.
A screenshot of that approach in action in my app:
http://funkeemonk.cachefly.net/international.png
Good luck!
Joe Goh
FunkeeMonk Technology
http://www.funkeemonk.com/
On 5/9/08, "Gary L. Wade" <email@hidden> wrote:
> Sorry, I misread your suggested method, but, as Adam points out, it still isn't
> adequate for someone who has free-styled 8-bit text with no idea what the original
> encoding was.
>
> >
> >On Wednesday, May 07, 2008, at 12:37PM, "Jean-Daniel Dupas"
> ><email@hidden> wrote:
> >>What make you think this function assumes an exact encoding ? This
> >>method is not the same than +[NSString
> >>stringWithContentsOfFile:encoding:error:].
> >>
> >>The method +stringWithContentsOfFile:usedEncoding:error: returns the
> >>sniffed encoding by reference using the second argument. At least
> >>that's what the documentation says: “ This method attempts to
> >>determine the encoding of the file at path.â€
> >>This method was introduced in Tiger, that's maybe why you never see it
> >>before.
> >
> >Unfortunately, that method doesn't work unless you have UTF-16 or UTF-32 with
> >a BOM on Tiger, which makes it less useful than it might be. On Leopard it
> >reads xattrs, then tries UTF-8 if it's not UTF-16/32, but it certainly doesn't
> >sniff encodings like TEC. I was never motivated enough to figure out TEC, so
> >basically ended up checking for BOM, trying UTF-8, and then using MacRoman if
> >all else failed.
> >
> >--
> >adam
_______________________________________________
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