2012-02-13 46 views
4

您好我在sqlite的如何正确读取和打印SQLite中的重音字符?

在数据库中创建一个iPhone应用程序的数据库有一句话奶油(含特殊字符(E)

但使用select语句它显示在日志

检索这个词时,

enter image description here

和在表视图细胞

enter image description here

那么如何在tableview单元格中打印特殊字符“è”?

+0

尝试是这样的:'海峡= [NSString的stringWithUTF8String: “E”];'其中E可以通过任何其他的char * – 2012-02-13 11:50:51

+0

HTTP:// WWW。 fileformat.info/info/unicode/char/221a/index.htm – 2012-02-13 11:51:59

+0

\ U00e8 http://www.fileformat.info/info/unicode/char/e8/index.htm – 2012-02-13 11:56:10

回答

4

使用这个从数据库中获取的数据 -

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

,并显示一个UILabel的COL1。

不要相信上的NSLog它会显示unicode字符作为\ U221a或这样的事情..只是通过这些字符串的UILabel,你是好去

+0

为我工作。谢谢。 – Tidane 2013-05-12 18:16:10

+0

辉煌,谢谢! – user3079872 2017-03-31 14:53:06

2

您必须将字符串转换为一个CString在拉丁编码,然后再改CString对象为UTF-8

NSString *notes = [item objectForKey:@"notes"] ; 

const char *n_c_string =[notes cStringUsingEncoding:NSISOLatin1StringEncoding];   
NSString *n = [NSString stringWithCString:notes_c_string encoding:NSUTF8StringEncoding]; 
相关问题