in reply to Re: HTTP::Server::PSGI outputs broken utf-8 strings
in thread HTTP::Server::PSGI outputs broken utf-8 strings
#!/usr/bin/perl -- use strict; use warnings; use HTTP::Server::PSGI; use Encode; my $app = sub { return [ 200, [ 'Content-Type' => 'text/html; charset=UTF-8', ], [ map { Encode::encode( 'UTF-8', $_ ) } ## turn to octets so + Plack::Util doesn't have to qq{<!DOCTYPE html><html lang="en-US"><meta charset="utf- +8"> <title> PSGI is Perl </title><body>}, Encode::decode( 'UTF-8', qq{<h1>I \xe2\x99\xa5 Perl</h1>} ## native "latin1" + string ), ## unicode string qq{<p>I \x{2665} Perl}, ## unicode string '<p>' . ( chr(9829) x 10 ), ## unicode string ], ]; }; my $server = HTTP::Server::PSGI->new( host => "127.0.0.1", port => 9091, timeout => 120, ); $server->run($app); __END__ http://127.0.0.1:9091/
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: HTTP::Server::PSGI outputs broken utf-8 strings
by jeffa (Bishop) on May 01, 2015 at 15:14 UTC | |
by Anonymous Monk on May 01, 2015 at 23:29 UTC |