I had a problem and was wondering whether my solution was any good:
* Problem *
In the browser, I enter "Lindstr?m" in a name field and save it to the
In the view template this value looks nice:
[% item.$column | html %] --> Lindstr?m
In the form, as the value of an input element, in the edit template, the
value looks weird, with ? being rendered as two chars (the multi-byte utf8
[% item.to_field(column).as_HTML %] --> <input type="text"
The browser uses utf-8 from the HTTP header (and/or the <meta> content
type, but it doesn't seem to matter that much). That's not a problem.
In SQLite I can see the double char when looking at the table with dbish,
but Perl seems to handle that correctly, because the ? is there in the
variable value when I look at it.
Class::DBI::AsForm emits HTML::Element objects. The problem seems to be
HTML::Element's as_HTML method which calls
HTML::Entities::encode_entities() and interprets the ? as two chars.
* Solution *
My solution was to explicitly leave everything alone, except for the
"normal" HTML chars:
[% item.to_field(column).as_HTML('<>&"\'') %] --> Lindstr?m
Now... is this a good solution? The right place to solve it? Is it the