Re: how to ignore accents? - Mailing list pgsql-novice

From Ennio-Sr
Subject Re: how to ignore accents?
Date
Msg-id 20050331234021.GA3832@deby.ei.hnet
Whole thread Raw
In response to Re: how to ignore accents?  (Michael Fuhr <mike@fuhr.org>)
Responses Re: how to ignore accents?  (Ennio-Sr <nasr.laili@tin.it>)
List pgsql-novice
* Michael Fuhr <mike@fuhr.org> [310305, 12:24]:
> On Thu, Mar 31, 2005 at 08:38:02PM +0200, Ennio-Sr wrote:
> > * Michael Fuhr <mike@fuhr.org> [300305, 17:42]:
> > >
>
> The example uses 8.0's dollar quoting; here's something that should
> work in earlier versions:
>
> CREATE FUNCTION unaccent(text) RETURNS text AS '
> BEGIN
>     RETURN translate($1, ''\342\347\350\351\352\364\373'', ''aceeeou'');
> END;
> ' LANGUAGE plpgsql IMMUTABLE STRICT;
>
> As I mentioned in another message, I tested with the SQL_ASCII
> encoding, so if you use a different encoding then you might need
> to make some changes -- the point is that you can use translate()
> to convert one character to another (e.g., an accented character
> to its unaccented equivalent).  You'll probably also want to add
> more characters to the translation strings -- they're just short
> examples for demonstration purposes.
>

OK, I tried the new version and the function was created. However,
something strange is still happening, maybe depending on the LC_ALL
setting. Although I created a new database with sql_ascii encoding and
changed my LC_ALL to 'C', after inserting an accented vowel, either
directly typing it when I was on LC_ALL=it.IT or with \code being on
LC_ALL=C, a select * from table will show all accented vowels whereas
the:
non_acc=> select * from parole where unaccent(parola) = 'cafe';

yealds:

ERROR: column "a^çéèe^o^u^" does not exist
CONTEXT: PL/pgSQL function "unaccent" line 2 at return

[the '^' is on the vowels but I cannot write these letters with ALT+code]

I will read the full documentation before any new attempts ...

Thanks again.
     Ennio

--
[Perche' usare Win$ozz (dico io) se ..."anche uno sciocco sa farlo.   \\?//
 Fa' qualche cosa di cui non sei capace!"  (diceva Henry Miller) ]    (°|°)
[Why use Win$ozz (I say) if ... "even a fool can do that.              )=(
 Do something you aren't good at!" (as Henry Miller used to say) ]

pgsql-novice by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: how to ignore accents?
Next
From: "Morgan Kita"
Date:
Subject: Variable length custom data types help