On May 30, 2014, at 9:59 PM, Trygve Inda <cocoa...@xericdesign.com> wrote: > I have a database file exported as text from FileMaker which has several > high-ASCII French characters. > > NSError* error = nil; > NSStringEncoding* enc = nil; > > NSString* contents = [NSString stringWithContentsOfFile:path > usedEncoding:enc error:&error]; > > > This works but enc and error are both nil after the method returns, even > though contents is correct. > > NSString* contents = [NSString stringWithContentsOfFile:path encoding: > NSASCIIStringEncoding error:&error]; > > This one returns no error but the high ASCII French acented chars are messed > up. > > NSString* contents = [NSString stringWithContentsOfFile:path encoding: > NSUTF8StringEncoding error:&error]; > > This returns error 261 (file can't be interpreted). > > So why in the first example is it working (no error) but also not returning > any encoding value?
You're calling -stringWithContentsOfFile:usedEncoding:error: incorrectly. Try this: NSError *error = nil; NSStringEncoding enc; NSString* contents = [NSString stringWithContentsOfFile:path usedEncoding:&enc error:&error]; Note that NSString may not be able to guess your file encoding correctly. If you can discover which encoding FileMaker actually uses you'll be better off. (MacRoman is a good guess.) -- Greg Parker gpar...@apple.com Runtime Wrangler _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com