However, doing this "manually" on everything you fetch out of a database, becomes tedious quickly. Since I frequently use the selectall_arrayref fetching methods, I created this little sub that could can "wrap" around such a call.
It expects the arrayref of arrayrefs as input, and also returns it. So you can "inline" the call to "_utf8_on_all_arrayref".
require Encode; # needs to be done only once in the beginning sub _utf8_on_all_arrayref { # For all the records specified # Switch on the UTF-8 flag for all values # Return the original reference foreach (@{$_[0]}) { Encode::_utf8_on( $_ ) foreach @{$_}; } $_[0]; } #_utf8_on_all_arrayref
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Switching on internal UTF-8 flaq on DBI result from database
by Aristotle (Chancellor) on Dec 14, 2003 at 17:19 UTC | |
by liz (Monsignor) on Dec 14, 2003 at 20:46 UTC | |
by Aristotle (Chancellor) on Dec 14, 2003 at 23:15 UTC |