From: | Ennio-Sr <nasr(dot)laili(at)tin(dot)it> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: how to ignore accents? |
Date: | 2005-03-31 23:40:21 |
Message-ID: | 20050331234021.GA3832@deby.ei.hnet |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
* Michael Fuhr <mike(at)fuhr(dot)org> [310305, 12:24]:
> On Thu, Mar 31, 2005 at 08:38:02PM +0200, Ennio-Sr wrote:
> > * Michael Fuhr <mike(at)fuhr(dot)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) ]
From | Date | Subject | |
---|---|---|---|
Next Message | Morgan Kita | 2005-04-01 03:45:12 | Variable length custom data types help |
Previous Message | Michael Fuhr | 2005-03-31 19:24:52 | Re: how to ignore accents? |