On Mon, 11 Oct 2004 17:25:16 +0200, Peter Gervai wrote:
I got wide char errors in undebuggable ways so here's my narrowing patch
for the print. If utf8_flag is off then changes wide characters to "~".
Saves lots of warnings in several cron scripts which seem to handle
utf8 on their behalf and I happen to be lazy to patch 'em all up
like I did with Article.pm. Pretty solution going to be the rewritten
EncodeObject...
The filter line is a good general use wide-char-killer for wherever
prints are complaining about wide characters (which is almost always
a sign that perl knows the string is utf8 and the program handles
it as it wasn't, like around Log/Syslog).
--- Sendmail.pm-20041013 2004-10-13 12:19:40.000000000 +0200
+++ Sendmail.pm 2004-10-13 12:29:59.000000000 +0200
@@ -62,15 +62,19 @@
$Arg.= ' '.quotemeta($_);
}
# send mail
+ my $utf8_flag=0;
if (open( MAIL, "| $Self->{Sendmail} $Arg")) {
# set handle to binmode if utf-8 is used
if( !defined( $Param{Charset} ) || $Param{Charset} =~ /utf-?8/i )
{
# if Charset is not defined, act on DefaultCharset
# if it is utf8, then go on and hope that DefaultCharset it
utf8, too :-@
$Self->{EncodeObject}->SetIO(\*MAIL);
+ $utf8_flag = 1;
}
print MAIL ${$Param{Header}};
print MAIL "\n";
+ # filter out wide characters (to "~") if file handle is not utf8
+ ${$Param{Body}} = join( '', map { ord($_)>0xff ? '~' : $_ }
split //, ${$Param{Body}} ) unless $utf8_flag;
print MAIL ${$Param{Body}};
close(MAIL);
# debug
--
Now using M2, Opera's e-mail client: http://www.opera.com/m2/