s/([^\0-\x7F])/'' . ord($1) . ';'/eg;
####
$proper_utf8 = pack 'U0a*', $raw_from_database;
####
s/([^\0-\xFF])/'' . ord($1) . ';'/eg;
####
use Interpolation;
tie %HTML, "Interpolation", \&escape; # works with global or with lexical: my %HTML
{
my %esc;
BEGIN {
%esc = ( '&' => '&', '<' => '<',
'>' => '>', '"' => '"', # if you want them
);
}
sub escape {
my $s = pack 'U0a*', shift;
$s =~ s/([&<>"])/$esc{$1}/g;
$s =~ s/([^\0-\x7F])/$esc{$1} ||= '' . ord($1) . ';'/ge;
return $s;
}
}
####
print qq(
$HTML{$article->{'title'}}
Publication Date: $HTML{$article->{'pub_date'}}
Author: $HTML{$article->{'author'}}
Price: $HTML{PrintablePrice($format_list[0])}
);