in reply to UTF-8 webpage output from MySQL
The problem is that HTML::Template doesn't support step one - it always reads templates as binary data. Once you mix that with decoded data, you're lost.
One solution is to use HTML::Template::Compiled, which is a drop-in replacement for HTML::Template, and which has the open_mode option to new - just create your templates with
use HTML::Template::Compiled; my $t = HTML::Template::Compiled->new( filename => 'mytemplate.phtml', open_mode => '<:encoding(UTF-8)', );
Another "solution" is to encode every string that is passed to HTML::Template, but this will make your code explode (in terms of size, anyway).
Update: a few debugging tips when dealing with charset issues:
2nd update: you might have confused "encode" and "decode" - you have to decode input data from the outside (Foreign data -> Perl text strings) and you have to encode data in the other direction (Perl text strings -> Rest of World).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: UTF-8 webpage output from MySQL
by boboson (Monk) on Jan 22, 2008 at 12:24 UTC | |
by moritz (Cardinal) on Jan 22, 2008 at 12:35 UTC | |
by boboson (Monk) on Jan 22, 2008 at 13:44 UTC | |
by moritz (Cardinal) on Jan 22, 2008 at 14:11 UTC | |
by boboson (Monk) on Jan 22, 2008 at 16:24 UTC |