Although Perl seems to handle UTF-8 correctly, this is not the case when reading data with DBI::MySQL. In disussions on CPAN and elsewhere, I read about the solution, to set the utf8 flag for the database data by calling Encode::decode_utf8.
I have still a problem with Encode::decode_utf8. If the string to be decoded is already UTF-8, Encode::decode_utf8 returns an empty string! There seems to be no way to check if decoding is necessary, because in both cases (decoding successful or empty string), the string to be decoded was marked as "not utf" when I test it with Encode::is_utf8 .
Is there a good way to avoid this problem?
And what will happen, if a future version of DBI and DBD already handles the SQL data correctly? Will the decoding still work, or do we have to re-write all scripts then?