Re: Remove diacritical marks in SQL

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Ji?í N?mec <konference(at)menea(dot)cz>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Remove diacritical marks in SQL
Date: 2007-01-12 21:58:36
Message-ID: 20070112215836.GA20949@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jan 12, 2007 at 10:16:22PM +0100, Ji?í N?mec wrote:
> Hello,
>
> I would like to remove diacritical marks from a string in a SQL query.
> I tried to convert a UTF8 string to ASCII but it doesn't work for me.
>
> SELECT convert('?????ýáíé','UTF8','SQL_ASCII')

I don't think postgres has any stuff builtin for that, but other
languages (like perl) have modules to do this kind of thing. The method
is to decompose the string to normal form D, strip the diacritics, and
recompose what's left.

Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Simon Riggs 2007-01-12 22:10:46 Re: Autovacuum Improvements
Previous Message Tom Lane 2007-01-12 21:41:57 Re: [GENERAL] Corrupt database? 8.1/FreeBSD6.0