I really have searched for the answer, but I didn't find my answer :(
The problem is non-english characters (French and Greek), with just english characters it works fine.
I get stuff out a sqlite database, wich goes flawlessly with English characters, but not with French or Greek ones.
At this point it goes wrong:
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK)
This return false, so the program doesn't go on.
I have read things about UTF-8 and UTF-16.
It would be sqlite3_open for UTF-8, and sqlite3_open16 for UTF-16.
When I use sqlite3_open16, it doesn't open at all.
I have to open databases with French characters and one with Greek.
Anyone knows what to do?
This is the code where I open the database:
startLanguage = the language where I start with, this is also the database name.
databasePath = the path to the database file. e.g.: /Users/joeranbosma/Library/Application Support/iPhone Simulator/5.0/Applications/80C89C95-418D-487F-B697-6BEA4B0DAA66/Documents/frans.sql
-(void) readWordsFromDatabase {
// Setup the database object
sqlite3 *database;
// Init the words Array
words = [[NSMutableArray alloc] init];
// Open the database from the users filessytem
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
// Setup the SQL Statement and compile it for faster access
NSString *mySQLstatement = [@"select * from " stringByAppendingString:startLanguage];
const char *sqlStatement = [mySQLstatement UTF8String];
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
// Loop through the results and add them to the feeds array
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
// Read the data from the result row
NSString *woordA = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
NSString *woordB = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
// Create a new word object with the data from the database
Word *word = [[Word alloc] initWithWordA:woordA wordB:woordB];
// Word *words = [[Word alloc] initWithWordName:aName description:aDescription url:aImageUrl];
// Add the word object to the words Array
[words addObject:word];
[word release];
}
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
}
Edit 1
I have found a solution!
If you put everything into one file, and make multiple tables it works.
I would love to know why this is, so if anybody knows I would appreciate that