• 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: stringWithContentsOfURL: usedEncoding: error:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stringWithContentsOfURL: usedEncoding: error:


  • Subject: Re: stringWithContentsOfURL: usedEncoding: error:
  • From: "Adam R. Maxwell" <email@hidden>
  • Date: Mon, 5 Jun 2006 21:16:57 -0700


On Jun 5, 2006, at 21:03, Greg Stark wrote:

Supposedly the usedEncoding version of the method tries to determine the encoding for you (at least according to the Strings Programming Guide for Cocoa). Apple's suggestion for reading data with unknown encoding is to try this method first. Also, I'd rather not specify the encoding if I don't have to because it will give me a little more flexibility later. I'm just not having much luck with it and am beginning to think it is broken.

It's not broken, but it's definitely of limited utility; I think it tries Unicode, then defaultCStringEncoding (but I can't find this documented at the moment). For read-only data, I usually try stringWithContentsOfURL; if it returns nil, I try UTF-8; it that returns nil, I use ISO Latin 1, which always returns something (even if it's wrong). If you're going to read/modify and write the file, though, you'd better use the correct encoding to avoid corrupting data.


Adam


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: stringWithContentsOfURL: usedEncoding: error:
      • From: Greg Stark <email@hidden>
References: 
 >stringWithContentsOfURL: usedEncoding: error: (From: Greg Stark <email@hidden>)
 >Re: stringWithContentsOfURL: usedEncoding: error: (From: Andy Lee <email@hidden>)
 >Re: stringWithContentsOfURL: usedEncoding: error: (From: Greg Stark <email@hidden>)
 >Re: stringWithContentsOfURL: usedEncoding: error: (From: Adam Leonard <email@hidden>)
 >Re: stringWithContentsOfURL: usedEncoding: error: (From: Greg Stark <email@hidden>)

  • Prev by Date: Re: stringWithContentsOfURL: usedEncoding: error:
  • Next by Date: Re: what is ABMetaDataController and why is it raising an exception?
  • Previous by thread: Re: stringWithContentsOfURL: usedEncoding: error:
  • Next by thread: Re: stringWithContentsOfURL: usedEncoding: error:
  • Index(es):
    • Date
    • Thread