我正在使用數據庫來獲取數據。在數據庫中有近750個問題。有些問題包含特殊字符,例如「,....,」等。但是,當獲取數據並在textview中打印它時,它會轉換爲「?」。是否有任何方法可以刪除這些數據符號的種類,並打印在原來的格式。點,逗號等被轉換成特殊符號「?」在iphone
我用下面的代碼獲取和在TextView中顯示。
qsql=[NSString stringWithFormat:@"Select * from mydata where col_1 = '365'"];
if(sqlite3_prepare_v2(database, [qsql UTF8String], -1, &statement, NULL) == SQLITE_OK) {
while (sqlite3_step(statement) == (SQLITE_ROW))
{
char *field0 = (char *)sqlite3_column_text(statement, 1);
char *field1 = (char *)sqlite3_column_text(statement, 2);
NSString *t1 = nil;
if(field0!=NULL){
t1 = [[NSString alloc] initWithUTF8String:field0];
//NSString *t1 = [[NSString alloc] initWithCString:field0 encoding:NSUTF8StringEncoding];
NSLog(@"%@jujuj" ,t1);
}
NSString *t2 = nil;
if(field1!=NULL){
t2 = [[NSString alloc] initWithUTF8String:field1];
NSLog(@"%@jhjhh" ,t2);
}
NSString *string=t1;
NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@",."];
string = [[string componentsSeparatedByCharactersInSet:doNotWant] componentsJoinedByString:@""];
NSLog(@"%@jhgkjghkjg",string);
//NSLog(@"%@ %@",Q_NO, Q_NO1);
tv.text=t1;
tv1.text=t2;
[t1 release];
[t2 release];
}
}
納拉亞納,有沒有辦法以正確的方式來打印文本view.also我沒有直接的文字像@「公羊。」在string.im從數據庫中獲取它,所以我如何修改我的code.please幫助我 – suji
你有........ – suji
你可以在從數據庫中檢索數據時編寫我的代碼 – Narayana