Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

initWithContentsOfFile:usedEncoding:error: Not working?



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.