$h4X4_|=73}{ has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to get Apache, Perl, HTML5 and UTF-8 to all work together in a web page.I'm just doing it wrong.
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 Also the Content-Length $byte_count never comes out correct.
The test code.
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.
Its still so new to me I have a feeling there is something not right...#!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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl UTF-8 serving HTML5
by davido (Cardinal) on May 29, 2016 at 17:50 UTC | |
by $h4X4_|=73}{ (Monk) on May 29, 2016 at 21:22 UTC | |
|
Re: Perl UTF-8 serving HTML5
by Anonymous Monk on May 29, 2016 at 19:06 UTC | |
by Anonymous Monk on May 29, 2016 at 19:45 UTC | |
by $h4X4_|=73}{ (Monk) on May 29, 2016 at 21:04 UTC | |
by Anonymous Monk on May 29, 2016 at 21:15 UTC | |
by $h4X4_|=73}{ (Monk) on May 29, 2016 at 21:33 UTC | |
|