问题与重音字符列排序sqlite的(A) [英] Problems ordering sqlite by a column with accented characters (Á)
问题描述
我有一个SQLite数据库,我需要由一些富人开始的话用重音字符列命令。这些项目正在有序的错误,他们出现在结果的结尾:
I have a sqlite database, and i need to order by a column that haves some words starting by a accented character. These items are being ordered wrong, they are appearing on the end of the results:
安东尼奥 BONZO Zeto 安吉拉
Antonio Bonzo Zeto Ángela
如何订购正确时,该列中的SQLite数据库富人的口音?
How can i order correctly when the sqlite database haves accents in that column?
感谢
推荐答案
为
... ORDER BY column COLLATE UNICODE
或
... ORDER BY column COLLATE LOCALIZED
<一个href="http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html">Reference:
在除了SQLite的默认 BINARY
配页机,机器人提供了两个以上,中局部
,它与系统的电流的变化语言环境,以及 UNI code
,这是统一code归类算法,而不是针对当前语言环境。
In addition to SQLite's default
BINARY
collator, Android supplies two more,LOCALIZED
, which changes with the system's current locale, andUNICODE
, which is the Unicode Collation Algorithm and not tailored to the current locale.
例如:
db.execSQL("CREATE TABLE foo(a TEXT);");
db.execSQL("INSERT INTO foo VALUES('Antonio'),('Bonzo'),('Zeto'),('Ángela');");
Cursor c = db.rawQuery("SELECT * FROM foo ORDER BY a COLLATE UNICODE", null);
while (c.moveToNext()) {
Log.d("foo", c.getString(0));
}
输出:
Ángela
Antonio
Bonzo
Zeto
这篇关于问题与重音字符列排序sqlite的(A)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!