Hello, I have problem, when starting my dancer aplication with plackup and in template use UTF8 characters such as "Čeština je pěkný jazyk". When I start aplication via Dancer start skript and after render the page, everything is ok. But when i start this via plackup and after render page i get message "body must be bytes and should not contain wide characters (UTF-8 strings)". This message is in file Plack/Middleware/Lint.pm in 'sub validate_res()' where test is: if (ref $res->[2] eq 'ARRAY' && grep utf8::is_utf8($_), @{$res->[2]}) { $croak->('body must be bytes and should not contain wide characters (UTF-8 strings).'); } When i comment this test the aplication, then run OK. I try this on http://github.com/sukria/ThisShit, when i put in main layout my UTF8 text "Čeština je pěkný jazyk". I think this problem is with plack, which can't use UTF8 text for rendering :(
Hello, Igor! I can repeat your problem using your directions. Looks like Plack::Middleware::Lint got enabled by default in development environments somewhere in April and together with Dancer::Template::TemplateToolkit it leads to your error. There is a simple way to workaround the error. You may switch to Template::Simple by commenting out "template" setting in config.yml. Proper fix would be to apply this patch to your Dancer: diff --git a/lib/Dancer/Template/TemplateToolkit.pm b/lib/Dancer/Template/Templa index 0e092db..4bdb717 100644 --- a/lib/Dancer/Template/TemplateToolkit.pm +++ b/lib/Dancer/Template/TemplateToolkit.pm @@ -19,6 +19,7 @@ sub init { my $tt_config = { ANYCASE => 1, ABSOLUTE => 1, + ENCODING => 'utf8', %{$self->config}, }; And then specify "charset: utf8" in config.yml. (to all: we should think about making charset: utf8 the default) Igor, can you test it? -- Alex Kapranoff. 2010/7/7 <igor.bujna@post.cz>
Hello, I have problem, when starting my dancer aplication with plackup and in template use UTF8 characters such as "Čeština je pěkný jazyk". When I start aplication via Dancer start skript and after render the page, everything is ok. But when i start this via plackup and after render page i get message "body must be bytes and should not contain wide characters (UTF-8 strings)". This message is in file Plack/Middleware/Lint.pm in 'sub validate_res()' where test is:
if (ref $res->[2] eq 'ARRAY' && grep utf8::is_utf8($_), @{$res->[2]}) { $croak->('body must be bytes and should not contain wide characters (UTF-8 strings).'); }
When i comment this test the aplication, then run OK. I try this on http://github.com/sukria/ThisShit, when i put in main layout my UTF8 text "Čeština je pěkný jazyk". I think this problem is with plack, which can't use UTF8 text for rendering :( _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
Le 07/07/2010 08:37, Alex Kapranoff a écrit :
Proper fix would be to apply this patch to your Dancer: diff --git a/lib/Dancer/Template/TemplateToolkit.pm b/lib/Dancer/Template/Templa index 0e092db..4bdb717 100644 --- a/lib/Dancer/Template/TemplateToolkit.pm +++ b/lib/Dancer/Template/TemplateToolkit.pm @@ -19,6 +19,7 @@ sub init { my $tt_config = { ANYCASE => 1, ABSOLUTE => 1, + ENCODING => 'utf8', %{$self->config}, };
And then specify "charset: utf8" in config.yml.
(to all: we should think about making charset: utf8 the default)
I agree, this should be fixed before we release 1.2 -- Alexis Sukrieh
On Wed, Jul 7, 2010 at 12:23, Alexis Sukrieh <sukria@sukria.net> wrote:
Le 07/07/2010 08:37, Alex Kapranoff a écrit :
Proper fix would be to apply this patch to your Dancer: diff --git a/lib/Dancer/Template/TemplateToolkit.pm b/lib/Dancer/Template/Templa index 0e092db..4bdb717 100644 --- a/lib/Dancer/Template/TemplateToolkit.pm +++ b/lib/Dancer/Template/TemplateToolkit.pm @@ -19,6 +19,7 @@ sub init { my $tt_config = { ANYCASE => 1, ABSOLUTE => 1, + ENCODING => 'utf8', %{$self->config}, };
And then specify "charset: utf8" in config.yml.
(to all: we should think about making charset: utf8 the default)
I agree, this should be fixed before we release 1.2
Since Igor confirmed this fixes his problem, I just sent a pull request to you about Dancer::Template::TemplateToolkit. As per defaulting "charset" setting to "utf8" I am not sure yet it will not break some rare cases. If you think we may allow some breakage for those people who ACCIDENTALLY get correct results with not so correct code then I would recommend this new default and may provide code and doc path.
Ok, its worked now. thank you.
------------ Původní zpráva ------------ Od: Alex Kapranoff <kapranoff@gmail.com> Předmět: Re: [Dancer-users] Problem with PLACK Datum: 07.7.2010 08:37:52 ---------------------------------------- Hello, Igor!
I can repeat your problem using your directions. Looks like Plack::Middleware::Lint got enabled by default in development environments somewhere in April and together with Dancer::Template::TemplateToolkit it leads to your error.
There is a simple way to workaround the error. You may switch to Template::Simple by commenting out "template" setting in config.yml.
Proper fix would be to apply this patch to your Dancer: diff --git a/lib/Dancer/Template/TemplateToolkit.pm b/lib/Dancer/Template/Templa index 0e092db..4bdb717 100644 --- a/lib/Dancer/Template/TemplateToolkit.pm +++ b/lib/Dancer/Template/TemplateToolkit.pm @@ -19,6 +19,7 @@ sub init { my $tt_config = { ANYCASE => 1, ABSOLUTE => 1, + ENCODING => 'utf8', %{$self->config}, };
And then specify "charset: utf8" in config.yml.
(to all: we should think about making charset: utf8 the default)
Igor, can you test it?
-- Alex Kapranoff.
2010/7/7 <igor.bujna@post.cz>
Hello, I have problem, when starting my dancer aplication with plackup and in template use UTF8 characters such as "Čeština je pěkný jazyk". When I start aplication via Dancer start skript and after render the page, everything is ok. But when i start this via plackup and after render page i get message "body must be bytes and should not contain wide characters (UTF-8 strings)". This message is in file Plack/Middleware/Lint.pm in 'sub validate_res()' where test is:
if (ref $res->[2] eq 'ARRAY' && grep utf8::is_utf8($_), @{$res->[2]}) { $croak->('body must be bytes and should not contain wide characters (UTF-8 strings).'); }
When i comment this test the aplication, then run OK. I try this on http://github.com/sukria/ThisShit, when i put in main layout my UTF8 text "Čeština je pěkný jazyk". I think this problem is with plack, which can't use UTF8 text for rendering :( _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
On Wednesday 07 July 2010 07:37:28 Alex Kapranoff wrote:
Proper fix would be to apply this patch to your Dancer: diff --git a/lib/Dancer/Template/TemplateToolkit.pm b/lib/Dancer/Template/Templa index 0e092db..4bdb717 100644 --- a/lib/Dancer/Template/TemplateToolkit.pm +++ b/lib/Dancer/Template/TemplateToolkit.pm @@ -19,6 +19,7 @@ sub init { my $tt_config = { ANYCASE => 1, ABSOLUTE => 1, + ENCODING => 'utf8', %{$self->config}, };
Rather than patching Dancer::Template::TemplateToolkit I believe you could also pass it in the config, e.g.: engines: template_toolkit: ENCODING: utf8 It may be safe in fact to make this the default, but we'd have to carefully consider whether that's likely to lead to breakage in any odd cases...
participants (4)
-
Alex Kapranoff -
Alexis Sukrieh -
David Precious -
igor.bujna@post.cz