Re: determining encoding on documents
Re: determining encoding on documents
- Subject: Re: determining encoding on documents
- From: Sherm Pendley <email@hidden>
- Date: Mon, 21 Jul 2003 14:33:42 -0400
On Monday, July 21, 2003, at 02:04 PM, Francisco Tolmasky wrote:
I've read it, but mostly I was concerned with opening files that my
app did not create. BBEdit has an autodetect for encodings. If
someone makes a UTF8 file in another program, I want them to be able
to read it from mine.
Short answer - there is no 100% foolproof way to detect it.
Long answer - you can reliably detect many types of Unicode by looking
for a BOM (Byte Order Marker), and make some fairly reasonable guesses
about other text types. Because it's not 100% guaranteed, you should be
sure to give your users a means to override the auto-detection.
Have you had a look at the TextEdit app in /Developer/Examples/AppKit/?
It provides an example of both aspects of doing this - it adds a
drop-down list to the open panel to allow users to specify the encoding
of the file they're opening, and tries to detect the encoding if the
user didn't specify one.
You might also want to have a look in the archives - if I remember
correctly, there was a thread about this a few months ago that lasted
for several days, in which someone (I forget who) described in detail
why auto-detection isn't very reliable.
sherm--
Heisenberg may have slept here.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.