Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I am facing issue in rendering some Chinese phrases in HTML format through emails.

北京香港马会会所

北京香港赛马会会所

I am using following code:

my $bytes = $input; my $sender = new Mail::Sender({ from => 'Sourav@ss.com', smtp => 'localhost', #! msg => $bytes, headers => "Date: ", on_errors => "die" }); my $mail_args = { to => 'Sourav.ss@ww.com', headers =>"date:", subject =>"DIP", multipart => "related" }; $mail_args->{charset}="UTF-8"; $mail_args->{b_charset}="UTF-8"; $mail_args->{encoding} ="BASE64"; $sender->OpenMultipart($mail_args); $sender->Part({ ctype => 'multipart/alternative'}); my $msg_part_args = { ctype => "text/html", disposition => "NONE", msg => $bytes, }; $msg_part_args->{charset}="UTF-8"; $msg_part_args->{b_charset}="UTF-8"; $msg_part_args->{encoding} ="BASE64"; $msg_part_args->{b_encoding} ="BASE64"; $sender->Part($msg_part_args); $sender->EndPart("multipart/alternative"); $sender->Close;

Please let me know how to solve the issue.

Replies are listed 'Best First'.
Re: Chinese Character Issue in email thru HTML format
by zwon (Abbot) on Aug 30, 2012 at 12:36 UTC

    Could you replace my $bytes = $input; with

    use utf8;
    my $bytes="北京香港马会会所";
    
    and show us email you receive with all the headers?

      I am using this, use utf8; In Unix, we are unable to give the Chinese characters. Actually we have fetch top 10 phrases and some of the phrases are not getting encoded properly.

      The headers are :

      HTTP/1.1 200 OK Cache-Control: no-cache, no-store Pragma: no-cache Content-Type: text/html; charset=utf-8 Content-Encoding: gzip Expires: -1 Vary: Accept-Encoding Server: Microsoft-IIS/7.5 X-OWA-Version: 14.1.339.2 X-OWA-EventResult: 0 X-AspNet-Version: 2.0.50727 X-Powered-By: ASP.NET X-UA-Compatible: IE=EmulateIE7 Date: Mon, 03 Sep 2012 05:53:26 GMT Content-Length: 5243

      The phrase is coming something like this: Phrase -> 蛹嶺コャ鬥呎クッ鬩ャ莨壻シ壽園.

      Please help me on this.

        These are HTTP headers, not email.