从sqlite数据库中检索希腊字符

时间:2012-01-11 00:44:07

标签: iphone sqlite unicode utf-8

我在从sqlite数据库中检索希腊字母时遇到问题。这些字母在我的sqlite数据库中,我可以从我的用户那里得到这些信件。这是我的代码:

NSString *selectedChapter = [SecondViewController chapterToSearch];

(几行之后)

 const char *sqlStatement=[[NSString stringWithFormat:@"SELECT * FROM samples WHERE chapter IN ('%@')",selectedChapter]UTF8String];

        if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
            if (sqlite3_prepare_v2(database, sqlStatement, -1, &selectStatement, NULL) != SQLITE_OK) {
                NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));   
            }
            while (sqlite3_step(selectStatement) == SQLITE_ROW) {

                NSString *chapterLetter  = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectStatement,0)];
}

它跳过'while'语句。任何帮助都会非常感激。

1 个答案:

答案 0 :(得分:0)

不应该是while (sqlite3_step(sqlStatement) == SQLITE_ROW) {