Basically I have a database where I get $lastname
, $firstname
, $rid
, $since
, $times
and $ip
from.
Using a Perl script, I format the data to send it via e-mail. Since the $lastname
and $firstname
can contain special chars (for instance ä, ü, ß, é,...) I first decode the strings.
my $fullname = decode("utf8", $lastname) . ', ' . decode("utf8", $firstname);
my $send = swrite(<<'END', $ip, $fullname, $rid, $since, $times);
@<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<<<<<< @>>END
Without decode
, the special chars are garbage (ä becomes À) and the rest is OK.
With decode
, everything is fine except the lines with name containing special chars have a couple of <
too many.
Why is that? And how do I remove them?
Edit: swrite
is from perldoc perlform
sub swrite {
my $format = shift;
$^A = '';
formline($format, @_);
return $^A;
}
Edit2: The problem is not the terminal nor STDOUT. I use:
use Mail::Sender;
use vars qw($sender);
#...
$sender->MailMsg({to => $mailto,
cc=> "",
bcc => "",
subject => "subject",
msg => $send});
And the characters are badly shown when receiving the email.
Edit 3:
The data I get is already scrambled. I get 'À' instead of 'ä' and that's why my format fails, because the number of chars decreases when using decode.