plack/Plack — pull request #429 by miyagawa (2013-09-08 19:42:52+00:00)
Title: Encode strings as UTF-8 when it has wide characters

This has been controversial for so long, and my canned response is that an app returning data that breaks PSGI speicfication is ok to break the app, and should these kind of errors be handled by Lint in the development.

Meanwhile, a) realistically it's not cool for apps to crash servers and b) if some of these PSGI violation only happens *sometimes* in the runtime, caching them with Lint might be difficult as well.

There should always be lines drawn, since there are many other ways to break HTTP::Server::PSGI as well by returning (for example) a hash for headers instead of arrays, and handling all of these mistakes in the server isn't realistic.

This should probably documented as part of the spec or guideline, but here's a quick fix on the reference server to catch such errors.

```
> perl -S plackup -E dev -e ' sub{[200,["Content-Type","text/plain"],["\x{3092}"]]}'
Wide character in syswrite at /Users/miyagawa/.plenv/versions/5.18.1/lib/perl5/5.18.1/darwin-2level/IO/Handle.pm line 481.
```