NAME

HTML::FormFu::Manual::Unicode - Working with unicode

DESCRIPTION

Working with unicode.

For a practical example, see the Catalyst application in the examples/unicode directory in this distribution.

ASSUMPTIONS

In this tutorial, we're assuming that all encodings are UTF-8. It's relatively simple to combine different encodings from different sources, but that's beyond the scope of this tutorial.

For simplicity, we're also going to assume that you're using Catalyst for your web-framework, DBIx::Class for your database ORM, TT for your templating system, and YAML format HTML::FormFu configuration files, with YAML::Syck installed. However, the principles we'll cover should translate to whatever technologies you chose to work with.

BASICS

To make it short and sweet: you must decode all data going into your program, and encode all data coming from your program.

Skip to "CHANGES REQUIRED" if you want to see what you need to do without any other explanation.

INPUT

Input parameters from the browser

Catalyst::Plugin::Unicode will decode all input parameters sent from the browser to your application - see "Catalyst Configuration".

Data from the database

DBIx::Class::UTF8Columns will decode all input retrieved from the database - see "DBIx::Class Configuration".

Your template files

Set TT to decode all template files - see "TT Configuration".

HTML::FormFu's own template files

Set HTML::FormFu to decode all template files - see "HTML::FormFu Template Configuration".

HTML::FormFu form configuration files

If you have YAML::Syck installed, your YAML format form configuration files will automatically be decoded by "load_config_file" in HTML::FormFu, which automatically sets $YAML::Syck::ImplicitUnicode = 1.

Your perl source code

Any perl source files which contain unicode must use the utf8 module.

OUTPUT

Data saved to the database

DBIx::Class::UTF8Columns will encode all data sent to the database - see "DBIx::Class Configuration".

HTML sent to the browser

Catalyst::Plugin::Unicode will encode all output sent from your application to the browser - see "Catalyst Configuration".

CHANGES REQUIRED

Catalyst Configuration

Add Catalyst::Plugin::Unicode to the list of Catalyst plugins:

    use Catalyst qw/ ConfigLoader Static::Simple Unicode /;

DBIx::Class Configuration

Add DBIx::Class::UTF8Columns to the list of components loaded, for each table that has columns storing unicode:

    __PACKAGE__->load_components(qw/ UTF8Columns HTML::FormFu PK::Auto Core /);

Pass each column name that will store unicode to utf8_columns():

    __PACKAGE__->utf8_columns(qw/ lastname firstname /);

TT Configuration

Tell TT to decode all template files, by adding the following to your myapp.yml Catalyst configuration file:

    'View::TT':
      ENCODING: UTF-8

HTML::FormFu Template Configuration

Make HTML::FormFu tell TT to decode all template files, by adding the following to your myapp.yml Catalyst configuration file:

    'Controller::HTML::FormFu':
      constructor:
        tt_args:
          ENCODING: UTF-8

AUTHORS

Carl Franks cfranks@cpan.org

COPYRIGHT

This document is free, you can redistribute it and/or modify it under the same terms as Perl itself.