--- MIME-tools-6.200_02/lib/MIME/WordDecoder.pm- 2003-06-27 17:54:37 +0000 +++ MIME-tools-6.200_02/lib/MIME/WordDecoder.pm 2004-08-20 08:13:45 +0000 @@ -747,17 +747,8 @@ package MIME::WordDecoder; ### Determine the default charset for this locale: -my $DefaultCharset; -{ - $DefaultCharset = $ENV{LC_CTYPE} || "en_US.ISO8859-1"; - $DefaultCharset =~ s/^\w+\.//; ### "en_US.ISO8859-1" => "ISO8859-1" - $DefaultCharset =~ s/^ISO(\w)/ISO-$1/i; - $DefaultCharset ||= "ISO-8859-1"; ### just in case -} - ### We now pump everything through Unicode by default. ### However, here's a hook for people who's Unicode support is broken. -if ($MIME::WordDecoder::NO_UNICODE) { } if ($MIME::WordDecoder::NO_UNICODE) { ### Add US-ASCII handler: @@ -772,8 +763,23 @@ $Default = $DecoderFor{"ISO-8859-1"}; } else { - ### Set up default: - $Default = MIME::WordDecoder::Unicode->new($DefaultCharset); + my $DefaultCharset; + { + $DefaultCharset = $ENV{LC_CTYPE} || "en_US.ISO8859-1"; + $DefaultCharset =~ s/^\w+\.//; ### "en_US.ISO8859-1" => "ISO8859-1" + $DefaultCharset =~ s/^ISO(\w)/ISO-$1/i; + $DefaultCharset ||= "ISO-8859-1"; ### just in case + } + + ### Set up default: + eval { + $Default = MIME::WordDecoder::Unicode->new($DefaultCharset); + }; + if ($@) { + warn __PACKAGE__ . ": $@"; + warn __PACKAGE__ . ": falling back to ISO-8859-1 (check LC_CTYPE)\n"; + $Default = MIME::WordDecoder::Unicode->new("ISO-8859-1"); + } } #{