[cgiapp] UTF-8 output
Cees Hek
ceeshek at gmail.com
Wed Nov 4 05:24:59 EST 2009
On Wed, Nov 4, 2009 at 6:15 PM, Michael Lackhoff
<lackhoff at zbmed.uni-koeln.de> wrote:
> On 03.11.2009 23:27 Cees Hek wrote:
>
>> However, I guess you should ensure that any data that you send to TT
>> is utf8 encoded.
>
> That's exactly the problem. I pass lots of RDBO objects into the
> templates and those should contain decoded (UTF-8 flag on) data, not
> UTF-8 octets, so I guess encoding the whole thing at the end might be
> the only practical option left in this situation.
Can't you get DBI to do the decoding for you? I think it will depend
on the DBD module you use, but it is quite easy with PostgeSQL:
http://search.cpan.org/dist/DBD-Pg/Pg.pm#pg_enable_utf8_(boolean)
I use Rose::DB as well and have the following in my base class:
__PACKAGE__->register_db(
domain => 'development',
type => 'main',
driver => 'Pg',
database => $NC::Config::database,
username => $NC::Config::database_username,
password => $NC::Config::database_password,
host => $NC::Config::database_host,
port => $NC::Config::database_port,
server_time_zone => 'Australia/Sydney',
european_dates => 1,
# Apache::DBI and Rose::DB choke when server side prepares are turned on
connect_options => {
pg_server_prepare => 0,
pg_enable_utf8 => 1,
},
post_connect_sql => "SET CLIENT_ENCODING TO 'UTF8';",
);
Cheers,
Cees
More information about the cgiapp
mailing list