in reply to Re: utf8 in perl
in thread utf8 in perl
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: utf8 in perl
by hippo (Archbishop) on Jul 05, 2018 at 14:00 UTC | |
by theravadamonk (Scribe) on Jul 05, 2018 at 16:57 UTC | |
by hippo (Archbishop) on Jul 05, 2018 at 17:15 UTC | |
by theravadamonk (Scribe) on Jul 17, 2018 at 05:53 UTC | |
by theravadamonk (Scribe) on Jul 10, 2018 at 04:19 UTC | |
|
Re^3: utf8 in perl
by Corion (Patriarch) on Jul 05, 2018 at 10:44 UTC |