[html-formfu] UTF-8 double encoding with HTML::FormFu

Andreas Marienborg omega at palle.net
Mon Apr 28 14:49:58 BST 2008


I haven't looked at the tar ball attached to the original post, but I  
do have several working applications using unicode and html::formfu.

The most important thing to remember is decode on the way in to you  
application, and encode on the way out.

I decode from the database, the client, templates etc on the way into  
catalyst, and encode to the browser, back to the db etc on the way out.


If you use .po-files, make sure you have the correct charset in the  
start of the file:

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE  
package.
# FIRST AUTHOR <EMAIL at ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
"Language-Team: LANGUAGE <LL at li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"  #####  HERE
"Content-Transfer-Encoding: 8bit\n"
On Apr 28, 2008, at 3:21 PM, Immofrance - Green-Acres wrote:


See the Content-Type there.

This will make the Catalyst plugin localize return unicode-strings  
(perl unicode strings) (Or so I belive). In turn you need to make sure  
Catalyst UTF-8 encodes everything, and for that the Unicode-plugin is  
nice.

I also use Template::Provider::Encoding to handle templates with utf-8  
in them (You only need it if you write templates in utf-8, its sort of  
the Template toolkit analogy for "use utf8; to handle utf-8 encoded  
source code).


Its important to try to understand the concepts before trying to fix  
things.



hope it might help some (although I realize its a big mess this email,  
but figured it would be better than nothing)


- andreas


> Hi,
>
> Looking at your example, I would recommend you to first look at:
> http://search.cpan.org/~cfranks/HTML-FormFu-0.02004/lib/HTML/FormFu/Manual/Unicode.pod
>
> It will tell you a correct configuration of your base yaml should  
> have been more:
> ---
> name: testI18N
> using_frontend_proxy: 1
> 'Controller::HTML::FormFu':
>  languages_from_context: 1
>  localize_from_context: 1
>  constructor:
>    tt_args:
>      ENCODING: UTF-8
>
> 'View::TT':
>  ENCODING: UTF-8
>
> And other stuffs as apparently this improve your example but is not  
> enough.
>
> Another solution is to get the working example from CPAN:
> wget http://search.cpan.org/CPAN/authors/id/C/CF/CFRANKS/HTML-FormFu-0.02004.tar.gz
> tar xfz HTML-FormFu-0.02004.tar.gz
> cd HTML-FormFu-0.02004/examples/
> perl scrip/unicode/
> perl script/unicode_server.pl
>
> So far I have been able to do everything starting from there. I  
> still have encodings problems as I want to use a 'po' dictionary  
> instead of 'pm', and it does not seems to work if I put 'use utf8;'  
> in the code.
>
> BGaly
>
>
>
> -----Message d'origine-----
> De : Ferruccio Zamuner [mailto:nonsolosoft at diff.org]
> Envoyé : dimanche 27 avril 2008 19:33
> À : HTML Form Creation, Rendering and Validation Framework
> Objet : [html-formfu] UTF-8 double encoding with HTML::FormFu
>
> Hi,
>
> I'm using HTML::FormFu just updated from the svn and I'd some  
> troubles of utf8 double encoding, then I've start a simple catalyst  
> project from scratch and attached it here.
>
> I hope that it can be useful to fix.
>
>
> Bye,             \fer
>
>
> _______________________________________________
> HTML-FormFu mailing list
> HTML-FormFu at lists.rawmode.org
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu




More information about the HTML-FormFu mailing list