[Petal] How to use UtF-8 characters in Petal Templates
Peter Mayr
mayr at hbz-nrw.de
Thu Sep 27 12:25:11 GMT 2012
Hi!
we really like the Petal Templating-Engine for our webservices, however
I ran into a small problem:
How can I use UTF-8 characters in Templates?
It seems to me that they are all encoded to ISO-Latin-1.
Here is a small test case:
testcase.pl
-----
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Petal;
print "Petal with options: output => XHTML\n";
my $Template = new Petal(
file => "test.xml",
output => 'XHTML',
);
print $Template->process();
print "\n\nPetal with options: output => XML\n";
$Template = new Petal(
file => "test.xml",
output => 'XML',
);
print $Template->process()."\n";
print "Petal with options: output => XHTML, decode_charset => utf-8\n";
my $Template = new Petal(
file => "test.xml",
output => 'XHTML',
decode_charset => 'utf-8',
);
print $Template->process();
print "\n\nPetal with options: output => XML, decode_charset => utf-8\n";
$Template = new Petal(
file => "test.xml",
output => 'XML',
decode_charset => 'utf-8',
);
print $Template->process()."\n";
-----
test.xml (file is UTF-8 acc. to emacs)
-----
?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ul xmlns:tal="http://purl.org/petal/1.0/">
<li>UTF-8 Umlaut: ä</li>
<li>HTML Entity: ü</li>
<li>Entity with Hex-Code:ü</li>
</ul>
-----
Does anyone of you have some tips or pointers?
Thanks in advance!
All the best,
Peter
--
Peter Mayr, MA LIS
hbz, Gruppe Portale
- DigiBib, Online-Fernleihe -
Postfach 270451, 50510 Köln, Deutschland
Telefon +49-221-40075-198, Fax +49-221-40075-190
mayr at hbz-nrw.de
http://www.hbz-nrw.de
More information about the Petal
mailing list