[html-formfu] unicode example / tutorial

Carl Franks fireartist at gmail.com
Tue Oct 16 15:24:36 GMT 2007


I've added a unicode example Catalyst application to
    trunk/HTML-FormFu/examples/unicode

If you `cd examples/unicode`, and then run `./script/unicode_server.pl`
to start the application, you can then view the app in your browser.

It shows examples of a page with unicode combined from a variety of
sources: in the template, in the form config, from a database, and
from DateTime::Locale via HTML::FormFu::Element::Date

At the moment, the TT view/form works fine, but I've had to locally
patch Template::Alloy to add support for the ENCODING setting,
otherwise alloy won't decode the template files.
I've submitted the patch to the Template::Alloy author, and he's
modifying it to get it working with alloy's caching - hopefully an
update with be released soon.

If you want to test it, replace the 'slurp' sub in your
Template/Alloy.pm with this:

sub slurp {
   my ($self, $file) = @_;
   open(my $fh, '<', $file) || $self->throw('file', "$file couldn't be
opened: $!");
   read $fh, my $txt, -s $file;

   if ($self->{'ENCODING'}) {
       eval { require Encode };
       if ($@) {
           warn "Encode module not found, 'ENCODING' config only
available on perl >= 5.7.3\n$@";
       } else {
           $txt = Encode::decode($self->{'ENCODING'}, $txt);
       }
   }

   return \$txt;
}

If you do this, then all the forms should look ok, with no
double-encoding or other such errors.
Hopefully we'll be able to use this as a baseline, to help figure out
unicode errors in the future.

I've also created a new doc - HTML/FormFu/Manual/Unicode.pod - to
explain how it's working.

Cheers,
Carl



More information about the HTML-FormFu mailing list