Perl + DBD-Oracle, problems with encoding when "PerlHandler

Perl + DBD-Oracle, problems with encoding when "PerlHandler

am 19.02.2010 11:47:51 von michael kapelko

Hello.
Here's a short script I used to find out the problem with the Apache::Regis=
try:

#!/usr/bin/perl -wT
use strict;
use warnings;
use CGI;
use DBI;
use DBI qw(:sql_types);
use encoding 'utf-8';

my $cgi =3D new CGI;
print $cgi->header(-type =A0  => "text/html",
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 -charset =3D> "utf-8");
print $cgi->start_html(-lang =3D> "ru-RU",
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 -title =3D> "Title");
print $cgi->h1("Title");
my $db =3D DBI->connect("DBI:Oracle:SID=3DELTC;HOST=3D10.102.101.4",
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0, , {Rai=
seError =3D> 1,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 AutoCommit =3D> 0,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 ora_charset =3D> "UTF8"});
my $query =3D "select name from swmgr2.vw_switches where sw_id_ip =3D
2315046666"; // Selects Russian "name" from DB in UTF-8, because on
the previouse line we asked Oracle to return data to us in UTF-8.
my $stmt =3D $db->prepare($query);
$stmt->execute();
my $name;
$stmt->bind_columns(undef, \$name);
$stmt->fetch();
$stmt->finish();
$db->disconnect();
print $cgi->p($name);
print $cgi->end_html();

When invoked directly by the shell or in web page WITHOUT "PerlHandler
Apache::Registry", the UTF-8 encoded string in Russian is printed just
fine. But when "PerlHandler Apache::Registry" is used, only ???? are
printed in web page.
Thanks.

Re: Perl + DBD-Oracle, problems with encoding when "PerlHandler

am 19.02.2010 17:33:43 von Perrin Harkins

On Fri, Feb 19, 2010 at 5:47 AM, michael kapelko wrote:
> When invoked directly by the shell or in web page WITHOUT "PerlHandler
> Apache::Registry", the UTF-8 encoded string in Russian is printed just
> fine. But when "PerlHandler Apache::Registry" is used, only ???? are
> printed in web page.

Check your headers. See if there's any difference in the headers sent
when this is run with Registry.

- Perrin