New importer, Nat. Geo. Wild.
[nonametv.git] / lib / UTF8DBI.pm
blob0e24f874e12c66dd62abb315b88cac49238e1671
1 # UTF8DBI.pm re-implementation by Pavel Kudinov http://search.cpan.org/~kudinov/
2 # originally from: http://dysphoria.net/code/perl-utf8/
3 # And patched again by Andrew Forrest, Jan 2007
5 use DBI 1.21;
6 use utf8;
7 use Encode;
9 package UTF8DBI; use base DBI;
10 sub _utf8_ {
11 if (ref $_ eq 'ARRAY') {_utf8_() foreach @$_ }
12 elsif (ref $_ eq 'HASH' ) {_utf8_() foreach values %$_ }
13 else {
14 Encode::_utf8_on($_);
15 $_ = '⁂malformed-UTF8‼' #die "Malformed utf8 string in database"
16 if (Encode::is_utf8($_) && ! Encode::is_utf8($_, 1));
18 $_;
22 package UTF8DBI::db; use base DBI::db;
24 sub selectrow_arrayref { return UTF8DBI::_utf8_ for shift->SUPER::selectrow_arrayref(@_) };
25 sub selectrow_hashref { return UTF8DBI::_utf8_ for shift->SUPER::selectrow_hashref (@_) };
26 sub selectall_arrayref { return UTF8DBI::_utf8_ for shift->SUPER::selectall_arrayref(@_) };
27 sub selectall_hashref { return UTF8DBI::_utf8_ for shift->SUPER::selectall_hashref (@_) };
28 sub selectcol_arrayref { return UTF8DBI::_utf8_ for shift->SUPER::selectcol_arrayref(@_) };
30 sub selectrow_array { @{shift->selectrow_arrayref(@_)} };
33 package UTF8DBI::st; use base DBI::st;
35 sub fetch { return UTF8DBI::_utf8_ for shift->SUPER::fetch (@_) };