Thread Apache error log erweitern
(55 answers)
Opened by ALE1981 at 2019-09-20 11:41
Das Problem lässt sich nachstellen.
foo.tmpl Code: (dl
)
123[% x %]456 index.pl Code (perl): (dl
)
1 2 3 4 5 6 7 use utf8; use Template qw(); my $template = Template->new; $template->process('foo.tmpl', { x => '☺' }); __END__ Wide character in print at …/lib/site_perl/5.30.0/x86_64-linux-thread-multi-ld/Template.pm line 167. 123☺456 Um herauszufinden, in welcher Vorlagedatei der Fehler auftritt, muss man Debugging anschalten: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 use utf8; use Template qw(); use Template::Constants qw(DEBUG_PROVIDER); my $template = Template->new(DEBUG => DEBUG_PROVIDER); $template->process('foo.tmpl', { x => '☺' }); __END__ [Template::Provider] creating cache of unlimited slots for [ . ] [Template::Provider] _fetch_path(foo.tmpl) [Template::Provider] searching path: ./foo.tmpl [Template::Provider] _fetch(./foo.tmpl) [Template::Provider] _load(./foo.tmpl, foo.tmpl) [Template::Provider] _compile(HASH(0x142dc80), <no compfile>) [Template::Provider] _store(./foo.tmpl, Template::Document=HASH(0x185e268)) [Template::Provider] adding new cache entry Wide character in print at …/lib/site_perl/5.30.0/x86_64-linux-thread-multi-ld/Template.pm line 167. 123☺456 Die Lösung des Problems liegt in der korrekten Ausgabekodierung, d.h. entweder muss der vierte Parameter in der Methode process gesetzt werden: Code (perl): (dl
)
1 2 $template->process('foo.tmpl', { x => '☺' }, \*STDOUT, { binmode => ':encoding(UTF-8)' }) or die $template->error; oder global: Code (perl): (dl
)
STDOUT->binmode(':encoding(UTF-8)'); So funktioniert es: Code (perl): (dl
)
1 2 3 4 5 6 7 8 use utf8; use Template qw(); my $template = Template->new; STDOUT->binmode(':encoding(UTF-8)'); $template->process('foo.tmpl', { x => '☺' }) or die $template->error; __END__ 123☺456 |