[Petal] How to use UtF-8 characters in Petal Templates

Peter Mayr mayr at hbz-nrw.de
Thu Sep 27 13:55:02 GMT 2012


Hi,

thanks very much for our helpful answer!

Am 27.09.2012 15:05, schrieb Stefan Seifert:
> Your issue is not with Petal, but with Perl in general.

I see, I was a bit confused because I saw the Entity-Translation in 
Petal::Entities in a - what looked to my emacs like a - iso-latin-1 file.
But of course, you are right, that has nothing to do with how it is 
eventually spit out by perl.

  $Template->process()
> gives you a Perl Unicode character string. It's your responsibility to encode
> it according to your needs (that would be UTF-8) on output. Simply doing a
> print in your test script will encode the character string to the platform
> encoding (usually latin-1).
>
> Same would  happen if you just printed some constant Unicode string:
> perl -E 'use utf8; say "ödögödöckö";'
>
> To get UTF-8 output, you could use binmode:
> perl -E 'use utf8; binmode STDOUT, ":utf8"; say "ödögödöckö";'

Great that works for me.

> Have a look at https://metacpan.org/module/perluniintro for further
> information about how to use Unicode in Perl. And remember: debugging
> character encoding problems _sucks_

Yes, I already found out about that...

Thanks again,

  regards

  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