在sqlite的重音搜索(机器人) [英] Accented Search in sqlite (android)
问题描述
我有一个专栏,其中的一些内容包含重音字母。 例如:Grambú
I have a column where some of the elements contain accented letters. eg : Grambú
我的要求是,当我搜索Grambu我应该得到Grambú的结果也是如此。
My requirement is that when I search for "Grambu" I should get "Grambú" in the results as well.
对于这个要求我尝试使用COLLATE NOCASE参数为特定的列。 但是,没有工作。
For this requirement I tried using "COLLATE NOCASE" parameter for that specific column. But that didnt work.
当我搜索的网络解决方案,我发现很多人建议的正常化重音字符 并创建基于它作为唯一的选择另一列。
When I searched for solutions in the web , I found many people suggesting normalizing the accented characters and creating another column based on it as the only option.
有这个问题的任何其他解决方案更容易?
Is there any other easier solutions to this problem?
推荐答案
COLLATE NOCASE
和只为ASCII 的26个大写字符。
COLLATE NOCASE
works only for the 26 upper case characters of ASCII.
设置数据库的区域,以一个已经使用重音字符支持<一href="http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#setLocale%28java.util.Locale%29"相对=nofollow> 的setLocale()
,并使用 COLLATE中局部
。
Set the database's locale to one that has accented character support using setLocale()
and use COLLATE LOCALIZED
.
您也可以尝试使用 COLLATE UNI code
。
但要注意此错误: SQLite的UNI code类破在ICS - 不再区分大小写
You may also try using COLLATE UNICODE
.
But beware of this bug: SQLite UNICODE sort broken in ICS - no longer case-insensitive.
检查的文档为提这两个排序器的Android系统。
Check the documentation for mention of these two collators in Android.
另外,请查阅此在线整理演示工具一>
这篇关于在sqlite的重音搜索(机器人)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!