Home: Perl Programming Help: Advanced:
(Hack) Which encoding works without warnings?


Feb 24, 2015, 4:36 AM

Views: 9630
(Hack) Which encoding works without warnings?

I do know that it is a wrong way. But there is no hope to set our server right. So I ask for a hack.

Our server uses byte strings to represent information internally. They are either UTF-8 or windows-1251.

When writing byte strings to a file (opened without using ":encoding(...)" and so using ISO-8859-1) it sometimes gives "Wide character in print" warning. I was assigned the task to eliminate this warning.

My question: Which encoding can I use instead of default ISO-8859-1 to eliminate the warning? In other words, I ask you to suggest me an encoding which uses all 256 codepoints, in order not to produce a warning on any particular codepoint.

(This post was edited by porton on Feb 24, 2015, 4:53 AM)


Feb 24, 2015, 4:52 AM

Views: 9629
Re: [porton] (Hack) Which encoding works without warnings?

Sorry, I was wrong. I assumed that `print` prints without recoding for all encodings. In reality (on our Unix system), it prints without recoding only for ISO-8859-1.

So I cannot just plug an other encoding. I need to invent something (or you can suggest me something).

Here is our real code:

    my ($ToEmail, $FromName, $FromEmail, $Subject, $Type, $Charset, $Msg, $Bcc) = @_; 

$Charset = $Charset =~ /125\d/ ? "windows-$Charset" : "utf-8";

if ($Msg && $FromEmail && $Subject && $FromName) {

open(MAIL,"|/usr/local/sbin/exim -t -f$EMAIL_FAILURE");
print MAIL qq~To: $ToEmail\n~;
print MAIL qq~Bcc: $Bcc\n~ if $Bcc;
# print MAIL qq~Bcc: $EMAIL_PAVEL\n~;
print MAIL qq~Return-Path: "Failures" <$EMAIL_FAILURE>\n~;
print MAIL qq~From: "$FromName" <$FromEmail>\n~;
print MAIL qq~Subject: $Subject\n~;
print MAIL qq~Content-Type: text/$Type; charset="$Charset"\n~;
print MAIL qq~\n~; # empty string between header and message
print MAIL qq~$Msg~;

return 0;

Please suggest what to do in our situation.


Feb 24, 2015, 6:19 AM

Views: 9626
Re: [porton] (Hack) Which encoding works without warnings?

Oh, I've solved the problem in an other way.