Hi, Thanks for directing me to good source.
Anyway, I wrote a simple perl code.
here' my code.
#!/usr/bin/perl
use CGI ':standard';
use strict;
use warnings;
use CGI::Carp 'fatalsToBrowser'; # use only for testing
use Encode qw(encode decode);
no warnings 'utf8';
print "Content-Type: text/html; charset=utf-8\n\n";
my $subject = "Room Rush \303\242\302\200\302\223 Enjoy 25% off on you
+r stay. (raw: Room Rush =?utf-8?b?4oCT?= Enjoy 25% off on your stay.)
+";
$subject =~ s/[^[:ascii:]]+//g; # get rid of non-ASCII characters
my $subject_decoded = decode("MIME-Header", $subject);
#my $subject_decoded = decode("MIME-B", $subject);
#my $subject_decoded = decode("MIME-Q", $subject);
print "\n";
print "<br/>";
print "subject: $subject \n\n";
print "<br/>";
print "subject_decoded: $subject_decoded \n\n";
here's what I get via web browser.
subject: Room Rush Enjoy 25% off on your stay. (raw: Room Rush =?utf-8?b?4oCT?= Enjoy 25% off on your stay.)
subject_decoded: Room Rush Enjoy 25% off on your stay. (raw: Room Rush – Enjoy 25% off on your stay.)
But, the word " raw: " still appears?
Is this code good? How to enhance it? Anyway, I spent many hours to write the code since I still learn perl
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|