#!/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/
In reply to Re^2: HTTP::Server::PSGI outputs broken utf-8 strings
by Anonymous Monk
in thread HTTP::Server::PSGI outputs broken utf-8 strings
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |