How to read and print accent character from SQLite?

hi I have an iPhone application database created in sqlite

the database has the word crème (with a special character (è)

but when you extract this word using the select statement, it appears the same way as in log

enter image description here

and in the table cell

enter image description here

so how to print the special character "è" in the table cell?

+4
source share
2 answers

use this to get data from a database -

NSString *col1 = [NSString stringWithCString:(char *)sqlite3_column_text(compiledStatement, 0) encoding:NSUTF8StringEncoding]; 

and map col1 to UILabel.

Do not believe in NSLog, it will show unicode characters like \ U221a or something like this .. just pass these lines to UILabel and you are good to go

+4
source

You need to convert the string to CString in latin encoding and then convert cstring to utf-8

 NSString *notes = [item objectForKey:@"notes"] ; const char *n_c_string =[notes cStringUsingEncoding:NSISOLatin1StringEncoding]; NSString *n = [NSString stringWithCString:notes_c_string encoding:NSUTF8StringEncoding]; 
+2
source

Source: https://habr.com/ru/post/1396177/


All Articles