• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [Q] What encoding method can be automatically detected?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Q] What encoding method can be automatically detected?


  • Subject: Re: [Q] What encoding method can be automatically detected?
  • From: Sherm Pendley <email@hidden>
  • Date: Thu, 1 Feb 2007 11:13:31 -0500

On Feb 1, 2007, at 9:28 AM, JongAm Park wrote:

According to Apple's document, it says that this method can determine encoding method used for the file whose file path is given.

	stringWithContentsOfFile:usedEncoding:error:

However, it can't determine if the content of a file is whether in Mac Roman, ISO Latin1, and so on.
However, if stringWithContentsOfFile:encoding:error is used with the Mac Roman encoding, it can open a file in ISO Latin1, etc.


So, it seems to me that the stringWithContentsOfFile:encoding:error can read from a file with the given encoding successfully, even though the real encoding method compatible to the given "encoding".
However for the stringWithContentsOfFile:usedEncoding:error it doesn't.


So.. can anyone tell me what encoding method the stringWithContentsOfFile:usedEncoding:error can detect?

If the file has a BOM, it can be used to identify UTF and distinguish among the various UTF encodings - UTF-8, UTF-16, etc. If all of the characters in the file are in the ASCII range (0-127), the file is ASCII.


What this method cannot do is distinguish among other 8-bit encodings, such as UTF-8 with no BOM, Mac Roman, ISO-8859-1, etc. There are no distinguishing characteristics that would allow those to be detected automatically.

sherm--

Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Follow-Ups:
    • Re: [Q] What encoding method can be automatically detected?
      • From: Nick Zitzmann <email@hidden>
References: 
 >[Q] What encoding method can be automatically detected? (From: JongAm Park <email@hidden>)

  • Prev by Date: Re: NSString encoding and perl script encoding
  • Next by Date: Re: NSTask & NSPipe to perl script
  • Previous by thread: [Q] What encoding method can be automatically detected?
  • Next by thread: Re: [Q] What encoding method can be automatically detected?
  • Index(es):
    • Date
    • Thread