Good day bros. I have some URLs and page titles that contain UTF-8 chars (French and Arabix). I am trying to write them to an HTML file like so: Use Encode;
.
.
.
open(OUT,">topurls.htm") or die "Can't open output: $!";
print OUT <<'END_HEADER';
<html>
<head>
<title>Top URLs</title>
<meta http-equiv="Content-Type" content="text/html; ch
+arset=utf-8">
</head>
<body>
<h3>Top URLs</h3>
<table cellpadding=10 border=1><tr><th>Link</th><th>Co
+unt</th><th>Users</th></tr>
END_HEADER
foreach my $u (keys %topurls) {
my @line;
$line[0] = '<a target="_blank" href="'.encode('UTF-8',$u).'">'.enc
+ode('UTF-8',$topurls{$u}{title}).'</a>';
$line[1] = $topurls{$u}{count};
$line[2] = $topurls{$u}{users};
print OUT '<tr><td>'.join('</td><td>',@line).'</td></tr>'."\n";
}
print OUT '</table></body></html>';
close OUT;
However in the resulting files, the characters are in the windoze charset. On the advice of a post somewhere else, I tried adding binmode(OUT,":utf8"); after the file open, no help. I also tried wrapping the encode statements in encode_entities from HTML::Entities. Also no help. How do I get these chars to output properly?
-
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.
|