Two starting points:
- In his answer to Why does modern Perl avoid UTF-8 by default? tchrist pointed out 52 things needed to ensure correct Unicode handling in Perl. The answer shows the boilerplate code with some
use
statements. A similiar question about the use of Unicode is How to make "use My::defaults" with modern perl & utf8 defaults? The PSGI spec is by design byte oriented. It is my responsibility to encode/decode everything, so for the Plack apps the correct way is to encode output and decode input, e.g.:
use Encode; my $app = sub { my $output = encode_utf8( myapp() ); return [ 200, [ 'Content-Type' =>'text/plain' ], [ $str ] ]; };
Is it correct to use
use uni::perl; # or any similar
in the PSGI application and/or in my modules?
uni::perl
changes Perl's default IO to UTF-8, thus:
use open qw(:std :utf8);
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");
binmode(STDERR, ":utf8");
Will doing so break something in Plack or its middlewares? Or is the only correct way to write apps for Plack explicitely encoding/decoding at open, so without the open
pragma?