Skip Menu |

This queue is for tickets about the Kelp CPAN distribution.

Report information
The Basics
Id: 84912
Status: resolved
Estimated: 20 min
Worked: 10 min
Priority: 0/
Queue: Kelp

People
Owner: MINIMAL [...] cpan.org
Requestors: MBETHKE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 0.2181
Fixed in: (no value)



Subject: UTF-8 issues with TT
Hi Stefan, I've just fixed a problem my app had with UTF-8 encoded templates in the default config, maybe you'd like to document that. To reproduce the bug, which is actually a TT problem: - Whip up a test app with "Kelp TestApp" - Change views/hello.tt to read "Hello, ☃" - Change the config route in lib/TestApp.pm to sub { return "Hello, ☃"; } and add a "use utf8;" below the package declaration. - Start plackup - Access both /home and /config with a browser The /config route's output has the snowman rendered correctly, the /home one reads "Hello, â". The Unicode snowman is U+2603 or e2 98 83 in UTF-8; e2 is â in Latin-1 while 98 iand 83 are undefined so they're not displayed (you get the other two bytes copied to the clipboard if you select the text in the browser though) Turns out TT can't properly deduce the template's encoding unless it has a BOM so writing to a file produces the correct output but rendering to a string doesn't set the UTF8 flag as it should (by the way, the "binmode => ':utf8'" in Kelp::Module::Template, while doing no harm, is redundant when rendering to a string). One can help TT by adding an entry to modules_init in the config file: Template => { ENCODING => 'utf8', } The ENCODING parameter is undocumented in TT's current CPAN version (cf. https://rt.cpan.org/Public/Bug/Display.html?id=64694) and I suppose UTF-8 for templates is a common choice so it would help having that documented or even added to the config already by the Kelp script. cheers, Matthias
Hi Matthias, You're right. Template does not render utf8 correctly, unless the ENCODING option is set. I added that option to the default configuration, together with some docs and tests, and it is scheduled to go out in the next release. In the meantime you can get the latest Kelp code from Github. Regards, Stefan On Mon Apr 29 02:56:45 2013, mbethke wrote: Show quoted text
> Hi Stefan, > > I've just fixed a problem my app had with UTF-8 encoded templates in > the default config, maybe you'd like to document that. To reproduce > the bug, which is actually a TT problem: > > - Whip up a test app with "Kelp TestApp" > - Change views/hello.tt to read "Hello, ☃" > - Change the config route in lib/TestApp.pm to > sub { return "Hello, ☃"; } > and add a "use utf8;" below the package declaration. > - Start plackup > - Access both /home and /config with a browser > > The /config route's output has the snowman rendered correctly, the > /home one reads "Hello, â". > > The Unicode snowman is U+2603 or e2 98 83 in UTF-8; e2 is â in Latin-1 > while 98 iand 83 are undefined so they're not displayed (you get > the other two bytes copied to the clipboard if you select the text > in the browser though) > > Turns out TT can't properly deduce the template's encoding unless it > has a BOM so writing to a file produces the correct output but > rendering to a string doesn't set the UTF8 flag as it should (by > the way, the "binmode => ':utf8'" in Kelp::Module::Template, while > doing no harm, is redundant when rendering to a string). One can > help TT by adding an entry to modules_init in the config file: > > Template => { > ENCODING => 'utf8', > } > > The ENCODING parameter is undocumented in TT's current CPAN version > (cf. https://rt.cpan.org/Public/Bug/Display.html?id=64694) and I > suppose UTF-8 for templates is a common choice so it would help > having that documented or even added to the config already by the > Kelp script. > > cheers, > Matthias