CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



porton
Novice

Feb 24, 2015, 4:36 AM

Post #1 of 3 (7945 views)
(Hack) Which encoding works without warnings? Can't Post

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)


porton
Novice

Feb 24, 2015, 4:52 AM

Post #2 of 3 (7944 views)
Re: [porton] (Hack) Which encoding works without warnings? [In reply to] Can't Post

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:


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~;
close(MAIL);

return 0;
}


Please suggest what to do in our situation.


porton
Novice

Feb 24, 2015, 6:19 AM

Post #3 of 3 (7941 views)
Re: [porton] (Hack) Which encoding works without warnings? [In reply to] Can't Post

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

Nevermind.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives