[dancer-users] UTF-8 in form POST

Warren Young warren at etr-usa.com
Fri Jun 27 14:55:39 BST 2014


On 6/26/2014 09:10, WK wrote:
>
> Actually, your code uses here STDERR and seems to me, that Dancer does
> not take care of it, so in your ./bin/app.pl <http://app.pl> you should
> add this:
>
>    binmode(STDERR, ":encoding(UTF-8)");

Thanks.  That solved the problem for me, indirectly.

I think Dancer::Logger::Console should do that when config.yml contains 
charset: "UTF-8".

It seems that Dancer::Logger::File already does the right thing when 
inserting param() data from a UTF-8 HTML form.  I wonder why there is a 
difference?

My test case boiled things down too far.  My real issue was different. 
It was yet another case of me thinking Perl somehow tags strings with 
their source encoding, so that data coming from a UTF-8 source and going 
out to a UTF-8 sink wouldn't need translation.  I needed to add an 
explicit encode('utf-8', $s) wrapper to that code path.

Your reply was still helpful, WK, in that it reminded me that Perl 
doesn't tag encoding that way, so thanks!

As advanced as Perl is in terms of its Unicode support, it's still more 
primitive than it should be.


More information about the dancer-users mailing list