comparing strings in PostgreSQL

Posted by binaryLV on Stack Overflow See other posts from Stack Overflow or by binaryLV
Published on 2010-06-16T08:39:28Z Indexed on 2010/06/16 8:42 UTC
Read the original article Hit count: 306

Filed under:
|
|

Hello!

Is there any way in PostgreSQL to convert UTF-8 characters to "similar" ASCII characters?

String glažškunu rukiši would have to be converted to glazskunu rukisi. UTF-8 text is not in some specific language, it might be in Latvian, Russian, English, Italian or any other language.

This is needed for using in where clause, so it might be just "comparing strings" rather than "converting strings".

I tried using convert, but it does not give desired results (e.g., select convert('A', 'utf8', 'sql_ascii') gives \304\200, not A).

Database is created with:

ENCODING = 'UTF8'
LC_COLLATE = 'Latvian_Latvia.1257'
LC_CTYPE = 'Latvian_Latvia.1257'

These params may be changed, if necessary.

© Stack Overflow or respective owner

Related posts about postgresql

Related posts about search