X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FUTF8.pm;h=999fc8a48fd6197b22261535e1e2d7292655a4a9;hb=1b1562614656acf70e9b69c8eb736673f370c816;hp=bc3a0faaaaeedd7da6c0a0aed19f50709b4c3e85;hpb=94c99b69df4bb1d9b4859b4796c99d0a4d9d4ae4;p=debbugs.git diff --git a/Debbugs/UTF8.pm b/Debbugs/UTF8.pm index bc3a0fa..999fc8a 100644 --- a/Debbugs/UTF8.pm +++ b/Debbugs/UTF8.pm @@ -28,7 +28,7 @@ charsets to UTF8. use warnings; use strict; use vars qw($VERSION $DEBUG %EXPORT_TAGS @EXPORT_OK @EXPORT); -use base qw(Exporter); +use Exporter qw(import); BEGIN{ $VERSION = 1.00; @@ -68,7 +68,7 @@ our $depth = 0; sub encode_utf8_structure { ++$depth; my @ret; - for my $_ (@_) { + for $_ (@_) { if (ref($_) eq 'HASH') { push @ret, {encode_utf8_structure(%{$depth == 1 ? dclone($_):$_})}; } @@ -179,11 +179,9 @@ sub convert_to_utf8 { # if there's an à (0xC3), it's probably something # horrible, and we shouldn't try to convert it. if (defined $call_back_data and $call_back_data !~ /\x{C3}/) { - warn "failed to convert to utf8 (charset: $charset, data: $data), but succeeded with ISO8859-1: ".encode_utf8($call_back_data); return $call_back_data; } } - warn "failed to convert to utf8 (charset: $charset, data: $data)"; # Fallback to encode, which will probably also fail. return __fallback_convert_to_utf8($data,$charset); } @@ -202,6 +200,10 @@ sub __fallback_convert_to_utf8 { } # lets assume everything that doesn't have a charset is utf8 $charset //= 'utf8'; + ## if the charset is unknown, assume it's UTF-8 + if ($charset =~ /unknown/i) { + $charset = 'utf8'; + } my $result; eval { $result = decode($charset,$data,0);