On Thu, Aug 01, 2002 at 10:09:58AM +0200, Andreas J. Koenig wrote:
A wrapper-function for fetchrow_array and fetchrow_hashref when the
database contains only UTF-8:
sub fetchrow {
my($self,$sth,$what) = @_; # $what is one of fetchrow_{array,hashref}
if ($] < 5.007) {
return $sth->$what;
} else {
require Encode;
if (wantarray) {
my @arr = $sth->$what;
for (@arr) {
defined && /[^\000-\177]/ && Encode::_utf8_on($_);
}
return @arr;
} else {
my $ret = $sth->$what;
if (ref $ret) {
for my $k (keys %$ret) {
defined && /[^\000-\177]/ && Encode::_utf8_on($_) for $ret->{$k};
}
return $ret;
} else {
defined && /[^\000-\177]/ && Encode::_utf8_on($_) for $ret;
return $ret;
}
}
}
}
Umm. Of course that'll break if the driver start doing it itself.
Tim.