在Android中使用SQLite的COLLATE - 区域设置在LIKE语句中忽略 [英] Using COLLATE in Android SQLite - Locales is ignored in LIKE statement
问题描述
在Android中创建我的SQLite数据库我设置数据库的语言环境 - db.setLocale(新的语言环境(cz_CZ))。这是一个捷克的语言环境。
When creating my SQLite database in Android I set the database locale - db.setLocale(new Locale("cz_CZ")). This is a Czech locale.
SELECT语句的作品,并采取语言环境考虑在内,例如:
A SELECT statement works and takes the locale into account, for example:
SELECT * from table WHERE name='sctzy' COLLATE LOCALIZED
会发现,进入ščťžý。
Will find the entry 'ščťžý'.
但是,使用像会失败:
SELECT * from table WHERE name LIKE '%sctzy%' COLLATE LOCALIZED
没有行返回。
BTW。没有java.text.Normalized类机器人。我想我可以做一个第二列具有标准化文本,剥夺了特殊字符,这将被用于搜索 - 但我缺少一类或方式如何规范化字符串
BTW. There is no java.text.Normalized class in Android. I thought I could make a second column with a normalized text, stripped of special characters, which would be used for searching - but I am missing a class or way how to normalize the String.
推荐答案
你吃过一看 SQLite的文档LIKE 的?它来了关于非ASCII字符和一个错误的信息。也许Android有SQLite的安装位置,这是一个问题的旧版本。
Have you had a look at the SQLite documentation for LIKE? It has come information about non ASCII characters and a bug. Maybe Android has an older version of SQLite installed where this is a problem.
我觉得第二归列可能是不幸的是您最好的选择。
I think the second normalised column might be your best option unfortunately.
这篇关于在Android中使用SQLite的COLLATE - 区域设置在LIKE语句中忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!