Hello,
I am have a small problem with Tempaltes and displaying UTF8 characters correctly. The data is stored in a SQLite database and a query with the code below displays the correct UTF8 characters. However, when I send the results to Template I get strange malformed characters.
This returns the data, at the console, correctly and shows displays the characters correctly. However, if I send $wah to tempaltes to be dereferenced the display looks like:#!/usr/bin/perl use strict; use DBI; use Data::Dumper; my $wah = wah(); print @$wah; sub wah { my $dbh = new_dbh(); my @results; my $sth = $dbh->prepare("select s.show_name,sr.overview,sr.banner from + shows s,series sr where s.seriesid=sr.seriesid;"); $sth->execute(); while (my @rows = $sth->fetchrow_array() ) { push @results,@rows, } return \@results; } sub new_dbh { my $dbh = DBI->connect("dbi:SQLite:dbname=shows.db","","", {RaiseE +rror => 1, sqlite_unicode => 1}) or die "$DBI::errstr"; return $dbh; }
Does anyone have any ideas what is going wrong? The data is being stored correctly in SQLite as a query from SQLite console shows the data correctly. Data::Dumper shows the characters correctly too, it's only when I send it to templates if fails over. I have tried my $template = Template->new({ ENCODING => 'utf8' }); but I am not sure if this works for Template at all.
UPDATE: OK, adding <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> to my header seems to have sorted this problem!
Nothing to see here, move along!!
In reply to Perl Template UTF8 by packetstormer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |