在PostgreSQL中转换重音字符? [英] Converting accented characters in PostgreSQL?

查看:161
本文介绍了在PostgreSQL中转换重音字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PostgreSQL中是否有一个现有函数用未修饰的字符替换重音字符? åø的字符应为 a o

Is there an existing function to replace accented characters with unadorned characters in PostgreSQL? Characters like å and ø should become a and o respectively.

我能找到的最接近的事情是translate函数, href =http://www.postgresql.org/docs/8.3/interactive/multibyte.html =nofollow noreferrer>此处。

The closest thing I could find is the translate function, given the example in the comments section found here.


一些常用的重音字符
可以使用以下
函数搜索:

Some commonly used accented characters can be searched using the following function:

translate(search_terms,
'\303\200\303\201\303\202\303\203\303\204\303\205\303\206\303\ 207\303\210\303\211\303\212\303\213\303\214\303\215\303\216\303\217\\ \\303\221\303\222\303\223\303\224\303\225\303\226\303\230\303\231\303 \232\303\233\303\234\303\235\303\237\303\240\303\241\303\242\303\ 243\303\244\303\245\303\246\303\247\303\250\303\251\303\252\303\253\\ \\303\254\303\255\303\256\303\257\303\261\303\262\303\263\303\264\303 \265\303\266\303\270\303\271\303\272\303\273\303\274\303\275\303\ 277','AAAAAAACEEEEIIIINOOOOOOUUUUYSaaaaaaaceeeeiiiooooouuuuyy')

translate(search_terms, '\303\200\303\201\303\202\303\203\303\204\303\205\303\206\303\207\303\210\303\211\303\212\303\213\303\214\303\215\303\216\303\217\303\221\303\222\303\223\303\224\303\225\303\226\303\230\303\231\303\232\303\233\303\234\303\235\303\237\303\240\303\241\303\242\303\243\303\244\303\245\303\246\303\247\303\250\303\251\303\252\303\253\303\254\303\255\303\256\303\257\303\261\303\262\303\263\303\264\303\265\303\266\303\270\303\271\303\272\303\273\303\274\303\275\303\277','AAAAAAACEEEEIIIINOOOOOOUUUUYSaaaaaaaceeeeiiiinoooooouuuuyy')


推荐答案

如果是这样,您可以使用此postgresql扩展,它提供了正确的Unicode归类。同一个群组有用于执行标准化的postgresql扩展

Are you doing this just for indexing/sorting? If so, you could use this postgresql extension, which provides proper Unicode collation. The same group has a postgresql extension for doing normalization.

这篇关于在PostgreSQL中转换重音字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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