[Catalyst] Catalyst, utf8 in form element type text

Marius Kjeldahl mariusauto-catalyst at kjeldahl.net
Sun May 4 23:09:32 BST 2008


I'm having a small problem that I hope somebody has a simple solution 
to. I'm using Catalyst with TT for the view, PostgreSQL and everything 
set up using utf8 (in perl source "use utf8", in postgres using 
"enable_utf8" and in the actual templates containing utf8 encoded 
interational characers). I've verified that the data stored in postgres 
is actually stored correctly (international characters in the postgres 
table display correctly in psql, and data pulled from both the database 
and templates show international characters fine).

Everything seems to work fine, with one small exception. Whenever I have 
a HTML form input type=text with an international character and the form 
validation fails, so the default value of the input field contains the 
international character, the rest of the html document does no longer 
display international characters correctly. If I remove the 
international character from the input field and resubmit, everything is 
displayed correctly again.

I'm guessing the browser detects that the document contains some element 
that is not proper utf8, and disables utf8 altogether before displaying 
whenever the input field contains an international characters.

The input field value is set in the template from the 
$c->req->parameters passed in the stash.

So my question is what's the best way to handle this? Can an input value 
in a form handle a utf8 encoded string at all, and if so how can I 
convince it my string is utf8, and if I do does the browser detect it 
automagically?

Any pointers?

Thanks,

Marius K.



More information about the Catalyst mailing list