my $dbh = DBI->connect($db{$dsn}{dsn},$db{$dsn}{user},$db{$dsn}{password},$db{$dsn}{opts});
if (!defined($dbh)) {
print "Error creating dbh: " . $DBI::errstr . "\n";
exit;
}
my $sth;
$sth = $dbh->prepare($query);
if (!$sth) {
print "Error: " . $dbh->errstr . "\n";
exit;
}
if (!$sth->execute) {
print "Error: " . $sth->errstr . "\n";
exit;
}
print "Content-Type: text/html; charset=utf-8\n\n";
my $ref = $sth->fetchrow_arrayref;
my $str = $$ref[0];
print $db{$dsn}{driver}." ".$str ." > ".join(" ",map {sprintf("0x%X",$_)} unpack("C*",$str))."\n";
####
# ./sql_test
Content-Type: text/html; charset=utf-8
Sybase школы#Касса > 0xD1 0x88 0xD0 0xBA 0xD0 0xBE 0xD0 0xBB 0xD1 0x8B 0x23 0xD0 0x9A 0xD0 0xB0 0xD1 0x81 0xD1 0x81 0xD0 0xB0
####
# ./sql_test
Content-Type: text/html; charset=utf-8
Pg школы#Касса > 0xD1 0x88 0xD0 0xBA 0xD0 0xBE 0xD0 0xBB 0xD1 0x8B 0x23 0xD0 0x9A 0xD0 0xB0 0xD1 0x81 0xD1 0x81 0xD0 0xB0
####
Sybase ?????#????? > 0x3F 0x3F 0x3F 0x3F 0x3F 0x23 0x3F 0x3F 0x3F 0x3F 0x3F
####
Pg школы#Касса > 0xD1 0x88 0xD0 0xBA 0xD0 0xBE 0xD0 0xBB 0xD1 0x8B 0x23 0xD0 0x9A 0xD0 0xB0 0xD1 0x81 0xD1 0x81 0xD0 0xB0