[html-formfu] FormFu and Unicode

Carl Franks fireartist at gmail.com
Mon Aug 13 15:57:40 GMT 2007


On 09/08/07, Tobias Kremer <list at funkreich.de> wrote:
>
> following up on my previous post about problems with the DateTime::Locale
> generated month names of the new date element I'd like to elaborate and discuss
> the topic a little bit more.
>
> IMHO, it all comes down to wrong Unicode handling. I see two potential problems
> concerning HTML::FormFu:
>
> 1) The YAML parser that reads the form definition must assure that the file is
> properly decoded (e.g. utf-8) into Perl's internal format.

This is the main issue.
Currently, YAML::Syck is mucking about with the internal utf8 flags,
so even it you pass LoadFile() a file handle opened with the correct
encoding, the values returned are not decoded, and so are
double-encoded when Catalyst::Plugin::Unicode::finalize() does it's
encode().

I've added a hack to load_config_file(), so that the contents returned
by filenames ending with 'yaml' or 'yml' are forcefully decoded.
I intend contacting the author of YAML::Syck though, to figure out the
correct solution.

> 2) The same goes for the TT snippets. TT has an undocumented option called
> "ENCODING" which should be set to whatever format the template files are (e.g.
> "utf-8") - See the Template::Provider source for details.

I've edited HTML::FormFu::Render::base::xhtml() to pass the "ENCODING
=> 'UTF-8'" option to TT.

You should also add this to your catalyst myapp.yml config file:
    View::TT:
      ENCODING: UTF-8

Carl



More information about the HTML-FormFu mailing list