[Dancer-users] problems with UTF-8

Mr. Puneet Kishor punk.kish at gmail.com
Sun Jun 12 21:15:59 CEST 2011

using Dancer 1.3051 (that I force-installed because it wouldn't install nicely on Mac OS X) with Apache. The config file says 

charset: "UTF-8"

A simple phrase like "EcoVal: a collaborative collection of casestudies" renders like so in Spanish and Portuguese respectively --

• EcoVal: colecci�n colaborativa de estudios

• EcoVal: uma cole��o colaborativa de estudos de caso

In my early days I used to use CGI::Application. I used the following to make sure everything rendered fine

sub translate {
	return encode_entities( decode_utf8( $_[0] ), "^\t\r\n\040-\177 " );

If I use the above with Dancer, it crashes and burn with the following mensaje. It actually doesn't tell me on which which line, in which package, did it find the offending malformed UTF-8 character (as far as I can tell). What should a polyglot do?

Malformed UTF-8 character (fatal) at (eval 59) line 1.

main in /Users/punkish/Sites/ecoval/public/dispatch.cgi l. 15
Plack::Runner in /usr/local/lib/perl5/site_perl/5.12.1/Plack/Runner.pm l. 231
Plack::Runner in /usr/local/lib/perl5/site_perl/5.12.1/Plack/Runner.pm l. 256
Plack::Loader in /usr/local/lib/perl5/site_perl/5.12.1/Plack/Loader.pm l. 83
Plack::Handler::CGI in /usr/local/lib/perl5/site_perl/5.12.1/Plack/Handler/CGI.pm l. 37
Plack::Component in /usr/local/lib/perl5/site_perl/5.12.1/Plack/Component.pm l. 39
Plack::Middleware::StackTrace in /usr/local/lib/perl5/site_perl/5.12.1/Plack/Middleware/StackTrace.pm l. 27
Try::Tiny in /usr/local/lib/perl5/site_perl/5.12.1/Try/Tiny.pm l. 67
Try::Tiny in /usr/local/lib/perl5/site_perl/5.12.1/Try/Tiny.pm l. 71
Plack::Middleware::StackTrace in /usr/local/lib/perl5/site_perl/5.12.1/Plack/Middleware/StackTrace.pm l. 27
Plack::Component in /usr/local/lib/perl5/site_perl/5.12.1/Plack/Component.pm l. 39
Plack::Middleware::Lint in /usr/local/lib/perl5/site_perl/5.12.1/Plack/Middleware/Lint.pm l. 24
Dancer::Handler in /usr/local/lib/perl5/site_perl/5.12.1/Dancer/Handler.pm l. 102
Dancer::Handler in /usr/local/lib/perl5/site_perl/5.12.1/Dancer/Handler.pm l. 71
Dancer::Handler in /usr/local/lib/perl5/site_perl/5.12.1/Dancer/Handler.pm l. 87
Dancer::Object in /usr/local/lib/perl5/site_perl/5.12.1/Dancer/Object.pm l. 15
Dancer::Error in /usr/local/lib/perl5/site_perl/5.12.1/Dancer/Error.pm l. 34
Dancer::Error in /usr/local/lib/perl5/site_perl/5.12.1/Dancer/Error.pm l. 248

More information about the Dancer-users mailing list