Re: utf8 encoding problem with plperlu

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: ron(at)yellowbank(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: utf8 encoding problem with plperlu
Date: 2015-07-15 14:34:23
Message-ID: 55A66F6F.8030003@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 07/15/2015 07:14 AM, Ronald Peterson wrote:
> The following short function illustrates a problem I'm having with the
> plperlu module.
>
> CREATE OR REPLACE FUNCTION
> doublezero ()
> RETURNS VOID
> AS $$
> use Encode qw/encode decode/;
> $pass = "double00";
> elog( INFO, "$pass" );
> $mspass = encode( 'UTF-16LE', qq("$pass") );
> elog( INFO, "$mspass" );
> $$ LANGUAGE plperlu
> STRICT;
>
> # select * from doublezero();
> INFO: double00
> CONTEXT: PL/Perl function "doublezero"
> ERROR: invalid byte sequence for encoding "UTF8": 0x00 at line 8,
> <DATA> line 558.
> CONTEXT: PL/Perl function "doublezero"
>
> I don't understand this. I need to pass $mspass to Active Directory,
> and it the encoding is exactly as it should be, which is to say, it
> works for strings that don't include two consecutive zeros. Is this a bug?

I am not a Perl user, but the question that came to mind is-

Does this:

mspass = encode( 'UTF-16LE', qq("$pass") )

work in Perl outside of plperlu?

>
> -R-
>
>
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Charles Clavadetscher 2015-07-15 14:45:14 Re: [9.5] question about row level security
Previous Message Ronald Peterson 2015-07-15 14:14:34 utf8 encoding problem with plperlu