From: scott.marlowe <scott.marlowe@ihs.com>
To: Michael A Nachbaur <mike@nachbaur.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: RFC: i18n2ascii(TEXT) stored procedure
Date: Fri, 26 Sep 2003 08:10:59 -0600 (MDT)
Message-ID: <Pine.LNX.4.33.0309260809350.21038-100000@css120.ihs.com> (raw)
In-Reply-To: <200309251650.53855.mike@nachbaur.com>
On Thu, 25 Sep 2003, Michael A Nachbaur wrote:
> I've created the following stored procedure to allow me to do
> international-insensitive text searches, e.g. a search for "Resume" would
> match the text "Résumé".
>
> I wanted to know:
>
> a) am I missing any characters that need to be converted? My first (and only
> language) is English, so I'm in the dark when that is concerned;
> b) is there a better and/or faster way of implementing this? I don't want
> searches to bog down (at least too badly) as a result of this.
>
> CREATE OR REPLACE FUNCTION i18n2ascii (TEXT) RETURNS TEXT AS '
> my ($source) = @_;
> $source =~
> tr/áàâäéèêëíìîïóòôöúùûüÁÀÂÄÉÈÊËÍÌÎÏÓÒÔÖÚÙÛÜ/aaaaeeeeiiiioooouuuuAAAAEEEEIIIIOOOOUUUU/;
> return $source;
> ' LANGUAGE 'plperl';
You could probably accomplish the same thing without using perl via the
built in function translate(). Look in the functions-string.html in the
7.3.x documentation.
Also, the regex version of substring() is quite powerful.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: scott.marlowe@ihs.com, mike@nachbaur.com
Subject: Re: RFC: i18n2ascii(TEXT) stored procedure
In-Reply-To: <Pine.LNX.4.33.0309260809350.21038-100000@css120.ihs.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox