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
In reply to Switching on internal UTF-8 flaq on DBI result from database by liz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |