• 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
initWithContentsOfFile:usedEncoding:error: Not working?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

initWithContentsOfFile:usedEncoding:error: Not working?


  • Subject: initWithContentsOfFile:usedEncoding:error: Not working?
  • From: Larry Fransson <email@hidden>
  • Date: Tue, 11 Apr 2006 00:05:31 -0700

I'm trying to initialize a string using NSString - initWithContentsOfFile:usedEncoding:error:. I'm getting an error (#261) that says the file can't be opened using the specified text encoding. This happens whether I specify an encoding or not. According to the docs, this method is supposed to try to determine the encoding used and return it by reference.

On the other hand, if I use -initWithContentsOfFile:encoding:error: and specify NSUTF8StringEncoding, it works fine. If I could count on the files I'm opening always being in UTF8 encoding, that would be great. But I'm not sure that's realistic given that TextEdit's default encoding for plain text is Mac OS Roman. I suppose the other solution is to iterate over every possible encoding until I don't get an error.

So am I using the first method the wrong way, or is not working?

Larry Fransson
Subcritical
_______________________________________________
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: initWithContentsOfFile:usedEncoding:error: Not working?
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Re: Cocoa Books
  • Next by Date: SLOW -[NSFileManager directoryContentsAtPath:matchingExtension:options:keepExtension:]
  • Previous by thread: Re: Help files no help
  • Next by thread: Re: initWithContentsOfFile:usedEncoding:error: Not working?
  • Index(es):
    • Date
    • Thread