Android的SQLite的分页/ ORDER BY UTF8 [英] Android SQLite collate/order by utf8

查看:217
本文介绍了Android的SQLite的分页/ ORDER BY UTF8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下Android上的SQLite表项(表选项卡有1列 - 名称文本)

I have following items in SQLite table on Android (table tab has 1 column - 'name' text)

Beta
Work
Úpal
User

如果我有排序规则斯洛伐克语在SQL Server中这些项目,而 SELECT * FROM按名称选项卡顺序,它正确输出排序的项目:

If I have these items in SQL Server with collation for Slovak language, and select * from tab order by name, it correctly outputs item sorted as:

Beta
User
Úpal
Work

在斯洛伐克语,U口音 - ü应该コ整理后

In Slovak language, U with accent - Ú should be sorted after U.

在Android上的SQLite,它输出它们顺序如下:

In SQLite on Android, it outputs them in this order:

Beta
User
Work
Úpal

我明白这是怎么回事,SQLite是使用字符code可能比较字符和U为W这样了。

I understand what's going on, SQLite is possibly comparing the characters using the character code, and Ú is after W that way.

我能做些什么来让我排序的方式?它甚至有可能?
上整理状态SQLite的文档,基本上所有的排序规则是二进制比较的变种,并做比较字符串数据使用memcmp(),不管文本编码。

What can I do to make it sort my way? Is it even possible? SQLite docs on COLLATION state that basically all collations are variants of binary comparison and do compare string data using memcmp(), regardless of text encoding.

推荐答案

的SQLite的C API允许安装新的排序规则序列的。
这些功能不是由Android的API公开,但至少安装两个额外的排序规则:

SQLite's C API allows to install new collation sequences. These functions are not exposed by the Android API, but at least it installs two additional collations:

除了SQLite的默认 BINARY 整理机,机器人提供了两个多, LOCALIZED ,它与系统的电流变化语言环境和 UNI code ,也就是统一code归类算法,而不是针对当前区域。

In addition to SQLite's default BINARY collator, Android supplies two more, LOCALIZED, which changes with the system's current locale, and UNICODE, which is the Unicode Collation Algorithm and not tailored to the current locale.

这篇关于Android的SQLite的分页/ ORDER BY UTF8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆