kravitz has asked for the wisdom of the Perl Monks concerning the following question:

Hello everyone.

I have to maintain one web application with old and rich history. Originally it ran on CGI, later it was "migrated" to mod_perl2, using ModPerl::Registry. After recent migration on new OS and hardware we faced several bugs, caused by CGI.pm and we decided to switch on mod_perl2 completely. I wrote a simple handler, everything works fine, but now it requires to explicitely decode utf-8 strings, that are fetched from DB (DBD::Firebird) (while previously it worked fine out-of-the-box, decoded them implicitly). What kind of smart stuff ModPerl::Registry does? I swear I didn't touched most of the original code of our application (except CGI.pm imports, now we use own wrapper on top of Apache2::Request).

And I realy don't want to modify hundreds of fetches from DB to explicitly decode utf-8 strings.

P.S. Those strings are passed into Template::Toolkit templater

Source code:
Handler
Wrapper, that replaces CGI.pm
Connection to DB

Best Regards,
Dmitry

Replies are listed 'Best First'.
Re: DBD::Firebird, mod_perl2 and utf-8
by zwon (Abbot) on May 17, 2012 at 14:42 UTC

    Maybe you should set ib_charset option?

      In fact this really helped me ― now all string data are decoded, I just need to decode few BLOB data, that really are utf-8 text data.

      But I still interesting why it all worked as-is with ModPerl::Registry? I read its source code, in fact it just makes eval on suplied filename, isolates its namespace and caches it. Is there some magic trick?

        I can't say for sure, but perhaps mod_perl sets UTF-8 encoding on output filehandler, and CGI don't