AxKit-XSP-CharsetConv
view release on metacpan or search on metacpan
CharsetConv.pm view on Meta::CPAN
#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#
#`,`, Parser subs `,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,#
#```````````````````````````````````````````````````````````````````#
sub parse_start {
my $e = shift;
my $tag = shift;
my %attr = @_;
if ($tag eq 'charset-convert') {
$attr{from} ||= 'iso-8859-1';
$attr{to} ||= 'utf-8';
$e->append_to_script("{ #start charset-convert\n");
$e->append_to_script(" my \$charconv = Apache::AxKit::CharsetConv->new('$attr{from}','$attr{to}');\n");
$e->append_to_script(" my \$to_convert = ''");
}
else {
die "Unknown tag $tag in CharsetConv taglib";
}
return '';
}
sub parse_end {
my $e = shift;
my $tag = shift;
if ($tag eq 'charset-convert') {
$e->append_to_script(";\n");
$e->start_expr;
$e->append_to_script(" \$charconv->convert(\$to_convert);");
$e->end_expr;
$e->append_to_script("} # end of charset-convs\n");
}
return '';
}
sub parse_char {
my $e = shift;
my $txt = shift;
$txt =~ s/\|/\\\|/;
CharsetConv.pm view on Meta::CPAN
1;
#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#
#`,`, Documentation `,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,#
#```````````````````````````````````````````````````````````````````#
=pod
=head1 NAME
AxKit::XSP::CharsetConv - AxKit XSP taglib for charset conversion
=head1 SYNOPSIS
Add the CharsetConv namespace to your XSP C<<xsp:page>> tag:
<xsp:page
language='Perl'
xmlns:xsp='http://apache.org/xsp/core/v1'
xmlns:conv='http://xmlns.knowscape.com/xsp/CharsetConv'>
CharsetConv.pm view on Meta::CPAN
The XSP CharsetConv taglib implements character set conversion as
implemented in iconv(), through the Apache::AxKit::CharsetConv module
that comes with your standard AxKit install. You may wish to use it
to convert data from misc. sources (databases, files, browser posts,
the environment, etc...) that are not UTF-8 yet need to be included in
the output of your XSP.
=head2 Tag Reference
There is only one tag provided by this taglib: charset-convert. It
has two mandatory attributes, from and to, which are the character
codes to convert (surprise) from and to.
The to attribute defaults to UTF-8, which usually makes sense. The from
attribute on the other hand defaults to ISO-8859-1. While this default
is very eurocentric, it would have been an arbitrary choice no matter
what my choice would have been... so I picked the one that's most
useful to me :-)
=head1 AUTHOR
AxKit::XSP::CharsetConv - AxKit XSP taglib for charset conversion
The XSP CharsetConv taglib implements character set conversion as
implemented in iconv(), through the Apache::AxKit::CharsetConv module
that comes with your standard AxKit install. You may wish to use it
to convert data from misc. sources (databases, files, browser posts,
the environment, etc...) that are not UTF-8 yet need to be included in
the output of your XSP.
( run in 0.400 second using v1.01-cache-2.11-cpan-4d50c553e7e )