Core data and special characters (UTF-8)
Posted
by MW
on Stack Overflow
See other posts from Stack Overflow
or by MW
Published on 2010-06-15T06:47:03Z
Indexed on
2010/06/15
6:52 UTC
Read the original article
Hit count: 551
I have an iPhone application using Core Data with an SQLite database in the bottom. I'm writing some text content from the database to a file, but special characters such as Å, Ä and Ö are corrupted in the file (they show up just fine in the application).
When creating and inserting data, I am not using any special encoding. I'm just taking the NSString (entered by the user in a UITextField) and putting it in my persistent objects. When saving the file, I use the following code:
[csvString writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:&error];
I tried adding a BOM to the beginning of the text ("\xef\xbb\xbf") but it is still corrupted. Anyone has any ideas where the problem might be?
Examples of corrupted characters: å becomes ö, ä becomes ä
© Stack Overflow or respective owner