--On Wednesday, July 10, 2002 11:38:11 +0200 Hans Juergen von Lengerke
<[EMAIL PROTECTED]> wrote:
> When running under mod_perl, TT prefers Apache::Util over
> HTML::Entities. However, Apache::Util doesn't escape all entities.
> Maybe it should be configurable what entity encoder to use. Or maybe
> there should be two additional filters which explicitly use one of the
> encoders rather than guessing which one to use.
There was some discussion about this on the modperl dev list a while ago.
The bottom line is that it's not possible to implement correctly unless
the data's character encoding is known. For this reason it is very
inprobable
that Apache::Util ever does more than it does now.
If you're outputting ISO-8859-1 (and sending out the appropriate response
header)
then you can be satistied with Apache::Util's minimal encoding.
>
> Here is a little example script to demonstrate. Note the difference in
> TT's output between command line and mod_perl:
> -------------------------------------------------------------------------
># !/usr/bin/perl -w
>
> use strict;
> use Template;
> use Apache::Util qw(:all);
> use HTML::Entities;
>
> print "ContentType: text/plain\n\n";
>
> print "Template Toolkit (version: $Template::VERSION):\n";
> my $data = "\t".'�: [% "�" | html_entity %]'."\n";
> $data .= "\t".'<: [% "<" | html_entity %]'."\n";
>
> my $tproc = Template->new();
> $tproc->process(\$data, {
> }) || die $tproc->error;
> print "\n";
>
> print "HTML::Entities (version: $HTML::Entities::VERSION):\n";
> print "\t�: ", HTML::Entities::encode("�"), "\n";
> print "\t<: ", HTML::Entities::encode("<"), "\n";
> print "\n";
>
> print "Apache::Util (version $Apache::Util::VERSION):\n";
> print "\t�: ", Apache::Util::escape_html("�"), "\n";
> print "\t<: ", Apache::Util::escape_html("<"), "\n";
> print "\n";
> -------------------------------------------------------------------------
>
>
> Run from the command line, this produces:
> -------------------------------------------------------------------------
> ContentType: text/plain
>
> Template Toolkit (version: 2.07):
> �: é
> <: <
>
> HTML::Entities (version: 1.13):
> �: é
> <: <
>
> Apache::Util:
> Undefined subroutine &Apache::Util::escape_html called at
> /home/lengerkeh/www/hosts/de/cgi-perl/rental/tt_html_entity.pl line 25.
> -------------------------------------------------------------------------
>
>
> Run under mod_perl (Apache::Registry) the output is:
> -------------------------------------------------------------------------
> Template Toolkit (version: 2.07):
> �: �
> <: <
>
> HTML::Entities (version: 1.13):
> �: é
> <: <
>
> Apache::Util (version 1.02):
> �: �
> <: <
> -------------------------------------------------------------------------
>
>
> _______________________________________________
> templates mailing list
> [EMAIL PROTECTED]
> http://www.template-toolkit.org/mailman/listinfo/templates
--
Eric Cholet