Reputation: 1737
I am encountering a problem concerning text-encoding on iPhone. I retrieve japanese characters from a sqlite database. So I get character like that ( their ASCII representation here : "& #25104;& #12395;& #12424;& #12427;" )
When I display these characters on a WebView, my japanese characters are well displayed. But when I try to display them on a UILabel, the ASCII representation is displayed rather than the japanese one.
I retrieve the text data from the database with the following function :
NSString *watchText = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)];
If anyone has an idea...
Upvotes: 1
Views: 1584
Reputation: 21882
That's because what you have is not an "ASCII representation". Those ("成による"
) are known as XML or HTML character entity references. As such, they only work if you parse them in an HTML context (like a web view).
What you need to do is either use a UIWebView for your labels, or parse the character entity references to turn them in to a normal NSString.
Upvotes: 2