Most likely, since you say only the first character is being compared, is that you have an ANSI/Unicode issue. Specifically, it sounds like a Unicode string is being passed to your collation function, which is expecting ANSI and then finding a 0 at the second byte is determining that that is the end of the string, thus exiting after the first character.
I have a collation function (Windows, code page 1252) that sounds like what you are doing. It was actually a bit complex to get it right (I think it's right). If you're interested, I could post it. -----Original Message----- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Roberto Colnaghi Sent: Thursday, August 25, 2011 1:59 AM To: sqlite-users@sqlite.org Subject: [sqlite] Custom Collation comparing only firt character? Hi, I'm using iOS SQLite with a custom collation. I've registered it: sqlite3_create_collation(sqlDatabase, "anyCIAI", SQLITE_UTF16, nil, collationAnyCIAI); And it is used like this: "select * from Team where Name = 'SOMETHING' COLLATE anyCIAI;" It works though only the FIRST character seems to be compared instead of the whole "Name". Is there anything missing here? The collation method should compare a á à ã... and so on as equal. Thank you! int collationAnyCIAI(void *arg1, int str1Length, const void *str1, int str2Length, const void *str2) { NSString *strA = [NSString hexStringWithData:str1 ofLength:1]; NSString *strB = [NSString hexStringWithData:str2 ofLength:1]; int striA; sscanf([strA cString], "%x", &striA); int striB; sscanf([strB cString], "%x", &striB); //convert to accentless //aA with accent to capital A if( (striA >= 192 && striA <= 197) || (striA >= 224 && striA <= 229) ){ striA = 65; } //çÇ to C if( striA == 199 || striA == 231 ){ striA = 67; } //eE with accent to capital E if( (striA >= 200 && striA <= 203) || (striA >= 232 && striA <= 235) ){ striA = 69; } //iI with accent to capital I if( (striA >= 204 && striA <= 207) || (striA >= 236 && striA <= 239) ){ striA = 73; } //oO with accent to capital O if( (striA >= 210 && striA <= 214) || (striA >= 242 && striA <= 246) ){ striA = 79; } //uU with accent to capital U if( (striA >= 217 && striA <= 220) || (striA >= 249 && striA <= 252) ){ striA = 85; } //a-z to A-Z if( striA >= 97 && striA <= 122 ){ striA -= 32; } //convert to accentless //aA with accent to capital A if( (striB >= 192 && striB <= 197) || (striB >= 224 && striB <= 229) ){ striB = 65; } //çÇ to C if( striB == 199 || striB == 231 ){ striB = 67; } //eE with accent to capital E if( (striB >= 200 && striB <= 203) || (striB >= 232 && striB <= 235) ){ striB = 69; } //iI with accent to capital I if( (striB >= 204 && striB <= 207) || (striB >= 236 && striB <= 239) ){ striB = 73; } //oO with accent to capital O if( (striB >= 210 && striB <= 214) || (striB >= 242 && striB <= 246) ){ striB = 79; } //uU with accent to capital U if( (striB >= 217 && striB <= 220) || (striB >= 249 && striB <= 252) ){ striB = 85; } //a-z to A-Z if( striB >= 97 && striB <= 122 ){ striB -= 32; } int result = striA - striB; return result; } _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users