Re: Translate function and strange results ...

From: Arjen Nienhuis <a(dot)g(dot)nienhuis(at)gmail(dot)com>
To: Hervé Piedvache <bill(dot)footcow(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Translate function and strange results ...
Date: 2009-11-01 17:05:14
Message-ID: 11ddbd200911010905m7640e8a2l9ccf295ab01fb049@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Nov 1, 2009 at 4:56 PM, Hervé Piedvache <bill(dot)footcow(at)gmail(dot)com>wrote:

base=# select translate('Hervé', 'é', 'e');
> translate
> -----------
> Herve
> (1 row)
>
> base=# select translate('Hervé', 'âàäéèêëïöôùüû', 'aaaeeeeioouuu');
> translate
> -----------
> Hervai
> (1 row)
>

You are actually doing something like:

select translate(E'Herv\xc3\xa9',
E'\xc3\xa2\xc3\xa0\xc3\xa4\xc3\xa9\xc3\xa8\xc3\xaa\xc3\xab\xc3\xaf\xc3\xb6\xc3\xb4\xc3\xb9\xc3\xbc\xc3\xbb',
E'aaaeeeeioouuu');

Which apparently translates \xc3 -> a and \xa9 -> i.

I don't know why it does that though. Maybe it's the server_encoding. What
does SHOW server_encoding; tell you?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John Burski 2009-11-01 19:27:33 createlang error(s)
Previous Message David Fetter 2009-11-01 17:03:42 Re: Windowing functions - future plans