Mahalakshmi.m <[EMAIL PROTECTED]> wrote: > What about Japanese Kanji? > Will sqlite sort all the Hiragana,Katakana,Kanji. > I am having some records with starting Unicode as follows. > > 6B4C Kanji ????25???? ????1 > 30A2 Katakana ???? > > I am storing it using sqlite3_bind_text16(). > > But if I sort the above two the Unicode with 6B4C comes first but my > desired output is > > 30A2 Katakana ???? > 6B4C Kanji ????25???? ????1
I can't reproduce this particular problem. Here's the test I wrote: #include <stdio.h> #include <sqlite3.h> int main() { sqlite3* db; sqlite3_open(":memory:", &db); sqlite3_exec(db, "create table t(id, text)", 0, 0, 0); sqlite3_stmt* insert; sqlite3_prepare(db, "insert into t(id, text) values (?, ?)", -1, &insert, 0); sqlite3_bind_int(insert, 1, 1); sqlite3_bind_text16(insert, 2, L"\u6B4C", -1, SQLITE_STATIC); sqlite3_step(insert); sqlite3_reset(insert); sqlite3_bind_int(insert, 1, 2); sqlite3_bind_text16(insert, 2, L"\u30A2", -1, SQLITE_STATIC); sqlite3_step(insert); sqlite3_finalize(insert); sqlite3_stmt* select; sqlite3_prepare(db, "select id, text from t order by text", -1, &select, 0); while (sqlite3_step(select) == SQLITE_ROW) { int id = sqlite3_column_int(select, 0); wchar_t* text = (wchar_t*)sqlite3_column_text16(select, 1); printf("id=%d text=%X\n", id, (int)text[0]); } sqlite3_finalize(select); sqlite3_close(db); return 0; } This program prints id=2 text=30A2 id=1 text=6B4C meaning that sorting is as expected. Figure out what you are doing differently. Note that, in general, there's more to collation than a simple memcmp that SQLite does. Consider for example U+30FD (Katakana Iteration Mark). As I understand, a string containing it should sort as if the preceding character was actually repeated: so ?? (U+30A2 U+30FD) should sort before ?? (U+30A2 U+30A4). Also consider halfwidth letters (e.g. U+FF71 Halfwidth Katakana Letter A) which are expected to be sorted near their fullwidth equivalents. Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users