sqlite中文排序相关
来源:互联网 发布:秋天 连衣裙 搭配 知乎 编辑:程序博客网 时间:2024/06/09 14:21
参考网址:http://blog.csdn.net/absurd/article/details/1271259
因为公司需要,用到sqlite,并需要中文排序。我在W3C school网站上学习了简单的sql语句,借用同事的C++封装完成了读取数据库内容。
中文排序是李先静大牛的介绍,折腾了数天,终于在PC上测试出如下结果:
slite> select * from person order by name collate pinyin;
李四|24
李四叔|24
王五|25
王五妹|25
张三|23
张三丰|23
赵七|26
赵七姑|26
至此,我应该能够加载自己的排序了。
遇到了如下问题,我给大家分享一下,希望能够减少初学者的学习路线。
1. 拼音比较算法:pinyin_cmp在李的评论里有个链接到github上。
2. 如何将pinyin文件编译链接到sqlite3的执行文件。我学习了李先静介绍的automake/autoconf。
3. 在哪里安装自定义的文件?我是通过<the definitive guide to sqlite>这边书中介绍知道如何安装的。最后安装到shell.c文件中的open_db函数后面。
int main(int argc, char **argv){char *sql; sqlite3 *db; int rc;/* For forming more consistent political opinions. */srand((unsigned)time(NULL));sqlite3_open("test.db", &db);/* Create issues table, add records. */setup(db);/* Register Collation. */fprintf(stdout, "1. Register political Collation\n\n"); sqlite3_create_collation( db, "POLITICAL", SQLITE_UTF8, db, political_collation );/* Turn SQL logging on. */log_sql(db, 1);/* Test default collation. */fprintf(stdout, "2. Select records using default collation.\n");sql = "select * from issues order by issue";print_sql_result(db, sql);/* Test Political collation. */fprintf(stdout, "\nSelect records using political collation. \n");sql = "select * from issues order by issue collate POLITICAL";print_sql_result(db, sql);fprintf(stdout, "\nSelect again using political collation. \n");print_sql_result(db, sql);/* Done. */sqlite3_close(db);return 0;}
0 0
- sqlite中文排序相关
- Sqlite中文排序研究
- Sqlite中文排序研究
- Sqlite中文排序研究
- Sqlite中文排序研究
- Sqlite中文排序研究
- Sqlite中文排序研究
- Sqlite中文排序研究
- Sqlite中文排序研究
- Sqlite中文排序研究
- Sqlite中文排序
- Sqlite中文排序研究
- Sqlite android 中文排序
- [转]Sqlite中文排序研究
- [转]Sqlite中文排序研究
- [转]Sqlite中文排序研究
- sqlite中文排序小诀窍
- sqlite不支持中文排序,采用java排序
- 均值滤波
- dll动态库开发-模拟socket通信
- log4j 详细使用
- 温故-C++ PRIMER 2014-11-23
- 如何把引用的jar包和本项目一起导出成jar文件
- sqlite中文排序相关
- Oracle之Check约束实例详解
- 将一个数组的非零元素移动到数组的前面,零元素置于数组的后面
- js如何判断用户是否是用微信浏览器
- yii 构建search 数据源data
- 捉虫经历
- php 时间戳
- jsp 乱码
- 栈和队列的基本操作实现