I am trying to get Apache, Perl, HTML5 and UTF-8 to all work together in a web page.
What is happening is I can see the HTML5 source code and the browser chrome thinks the encoding is utf-8.
At this point I can not tell if its the server that could need an update or
I'm just doing it wrong. Also the Content-Length $byte_count never comes out correct.
The test code.

#!perl $rendered = <<HTML; <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Title of the document</title> </head> <body> <p>Test</p> </body> </html> HTML require Encode; $rendered = Encode::decode(utf8 =>$rendered); my $byte_count = length $rendered; print <<HTML; Content-Length: $byte_count Content-Type: text/plain; charset=utf-8 HTML binmode STDOUT, ":encoding(utf8)"; print $rendered; exit;

Update: I got it to work. Viewing the source problem was the header text/plain, I needed text/html. The "Content-Length" issues was

the fact I was on windows.

#!perl my $smiley = chr(0x263a); #"\x{263a}" my $rendered = <<HTML; <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Title of the document</title> </head> <body> <p>Test HTML my $rendered2 = <<HTML; </p> </body> </html> HTML # embed a Unicode character :) $rendered .= $smiley; # render footer $rendered .= $rendered2; use Encode qw{encode}; # [id://1164454] binmode STDOUT, ":raw"; $rendered = encode(utf8 =>$rendered); my $byte_count = length($rendered); print <<HTML; Content-Length: $byte_count Content-Type: text/html; charset=utf-8 HTML print $rendered; exit;
Its still so new to me I have a feeling there is something not right...


In reply to Perl UTF-8 serving HTML5 by $h4X4_&#124;=73}{

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.