Re: plperlu problem with utf8

From: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: plperlu problem with utf8
Date: 2010-12-08 16:13:08
Message-ID: Pine.LNX.4.64.1012081912200.12632@sn.sai.msu.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

adding utf8::decode($_[0]) solves the problem:

knn=# CREATE OR REPLACE FUNCTION url_decode(Vkw varchar) RETURNS varchar AS $$
use strict;
use URI::Escape;
utf8::decode($_[0]);
return uri_unescape($_[0]);
$$ LANGUAGE plperlu;

Oleg
On Wed, 8 Dec 2010, Andrew Dunstan wrote:

>
>
> On 12/08/2010 10:13 AM, Oleg Bartunov wrote:
>> Hi there,
>>
>> below is the problem, which I don't have when running in shell. The
>> database is in UTF-8 encoding.
>>
>> CREATE OR REPLACE FUNCTION url_decode(Vkw varchar) RETURNS varchar AS $$
>> use strict;
>> use URI::Escape;
>> return uri_unescape($_[0]); $$ LANGUAGE plperlu;
>> CREATE FUNCTION
>> Time: 1.416 ms
>> select url_decode('comment%20passer%20le%20r%C3%A9veillon');
>> url_decode ------------------------------
>> comment passer le rveillon
>> ^
>> non-printed
>
>
> I get: (platform is Fedora 13, git tip, perl 5.10.1):
>
> andrew=# CREATE OR REPLACE FUNCTION url_decode(Vkw varchar) RETURNS
> varchar AS $$
> andrew$# use strict;
> andrew$# use URI::Escape;
> andrew$# return uri_unescape($_[0]); $$ LANGUAGE plperlu;
> CREATE FUNCTION
> andrew=# select url_decode('comment%20passer%20le%20r%C3%A9veillon');
> url_decode
> ------------------------------
> comment passer le r?©veillon
> (1 row)
>
> andrew=#
>
> which makes it look like we might have some double escaping going on here,
> but at least I don't get nothing :-)
>
> Further experimentation shows even more weirdness. There's definitely
> something odd about the utf8 handling. Will dig further.
>
> cheers
>
> andrew
>
>
>

Regards,
Oleg
_____________________________________________________________
Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru),
Sternberg Astronomical Institute, Moscow University, Russia
Internet: oleg(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(495)939-16-83, +007(495)939-23-83

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Janes 2010-12-08 16:27:11 Re: random write in xlog?
Previous Message Tom Lane 2010-12-08 16:09:17 Re: pg_type.typname of array types.