Re: [Maypole-dev] UTF-8 problem with Maypole and Class::DBI::AsForm / HTML::Element

From: Kester Habermann (kester.habermann at gmail.com)
Date: Wed Dec 15 2004 - 00:20:27 GMT


Hi,

On Tue, 14 Dec 2004 23:31:50 +0000, Simon Flack <sf at flacks.net> wrote:
> utf8 is a lexical pragma that tells perl that the source code is utf8,
> so in your example, that string ("À") has its utf8 flag on.

OK. You're right. My mistake I was trying this in the debugger and of course
"use utf8" would "fix" the problem there.
 
> This also works without utf8.pm:
>
> use HTML::Element;
> print HTML::Element->new("textarea", name => "lala")
> ->push_content(chr(228))->as_XML;
> <textarea name="lala">&#228;</textarea>
>
> Are you sure the value you're getting back from the database is
> correctly encoded?

Thanks for pointing me in the right direction. Maypole stores the
correct utf-8 value
in the database, this works fine. The data I get back from the DB is
correctly encoded,
but the utf-8-flag is not set. For postgres setting pg_enable_utf8
does the trick (see file).
Then everything works fine with HTML::Element. So it's not a bug in
AsForm after all.

Without the pg_enable_utf8 the script outputs:
<textarea name="name">&#195;&#164;</textarea>

with the option everything works fine:
<textarea name="name">&#228;</textarea>

As the maypole default is utf-8 and the standard BeerDB does not work
with non-ascii
characters it may be usefull to know this.

Kester.





This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:57 GMT