开发者

Converting accented characters in PostgreSQL?

开发者 https://www.devze.com 2022-12-10 04:16 出处:网络
Is there an existing function to replace accented characters with unadorned characters in PostgreSQL?Characters like å and ø should become a and o respectively.

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

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\开发者_C百科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')


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消