Обсуждение: BUG #6344: Trouble with plperl

Поиск
Список
Период
Сортировка

BUG #6344: Trouble with plperl

От
k_denisov@inbox.ru
Дата:
The following bug has been logged on the website:

Bug reference:      6344
Logged by:          Kirill
Email address:      k_denisov@inbox.ru
PostgreSQL version: 9.1.2
Operating system:   Linux Debian
Description:=20=20=20=20=20=20=20=20

plperl function:
open(FILE,">>/test/test.txt");
print FILE "=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0(Cyrillic text)=
";
close FILE;
Base codepage and client codepage cp1251.
Record in file broken codepage.

Re: BUG #6344: Trouble with plperl

От
Alex Hunsaker
Дата:
On Sun, Dec 18, 2011 at 01:25,  <k_denisov@inbox.ru> wrote:
> The following bug has been logged on the website:
>
> Bug reference: =C2=A0 =C2=A0 =C2=A06344
> Logged by: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Kirill
> Email address: =C2=A0 =C2=A0 =C2=A0k_denisov@inbox.ru
> PostgreSQL version: 9.1.2
> Operating system: =C2=A0 Linux Debian
> Description:
>
> plperl function:
> open(FILE,">>/test/test.txt");
> print FILE "=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0(Cyrillic tex=
t)";
> close FILE;
> Base codepage and client codepage cp1251.
> Record in file broken codepage.

Im not exactly sure what you are saying, but my hunch is you need to
use Encode or give the file handle an encoding:
binmode(FILE, ':encoding(cp1251)'); (or via open)

or

use Encode qw(encode);
my $str =3Ddecode("cp1251", "=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=
=B0(Cyrillic text));
print FILE $str;