I would like to create a collation in order to make case insensitive and no accents searches in a database.
here is my code :
static int sqlite3NoCaseNoAccentCollate(void * foo, int ll, const void *l, int rl,
const void *r){
NSLog(@"comparing");
NSString *left = [NSString stringWithCharacters:l length:ll];
NSString *right = [NSString stringWithCharacters:r length:rl];
NSComparisonResult rs = [left compare:right options:NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch|NSForcedOrderingSearch];
NSLog("%d",rs);
return rs;
}
sqlite3 *db;
if (SQLITE_OK==sqlite3_open([pathToDataBase UTF8String], &db)){
sqlite3_create_collation(db, "MYNOCASENOACCENT", SQLITE_UTF8, NULL, &sqlite3NoCaseNoAccentCollate);
}
When I execute this query :
SELECT ('teste' LIKE 'testé' COLLATE MYNOCASENOACCENT)
it returns 0 instead of 1, and my custom function is never called (I put breakpoints in the function to test).
When I list all the collations by using "PRAGMA collation_list", my custom collation exists.
Any idea of the problem ?