Template::Plugin::UTF8Decode - UTF8 decoder filter for Template Toolkit


Template-Plugin-UTF8Decode documentation Contained in the Template-Plugin-UTF8Decode distribution.

Index


Code Index:

NAME

Top

Template::Plugin::UTF8Decode - UTF8 decoder filter for Template Toolkit

SYNOPSIS

Top

  [% USE UTF8Decode %]

  [% ansi_string_var | utf8_decode | html_entity %]

DESCRIPTION

Top

This module is a Template Toolkit filter, which decode a string to utf8. For example, using FreeTDS (http://www.freetds.org) in order to talk with ms sql, can return an utf8 string as byte char.

METHODS

Top

init

Installs the filter as 'utf8_decode'.

filter

Receives a reference to the plugin object, along with the text to be filtered.

AUTHOR

Top

Fabio Masini <fabio.masini@gmail.com>

COPYRIGHT AND LICENSE

Top


Template-Plugin-UTF8Decode documentation Contained in the Template-Plugin-UTF8Decode distribution.

package Template::Plugin::UTF8Decode;

use 5.006;
use strict;

our $VERSION = '0.01';

my $FILTER_NAME = 'utf8_decode';

use Template::Plugin::Filter;
use base qw( Template::Plugin::Filter );

sub init {
    my $self = shift;

    $self->install_filter($FILTER_NAME);

    return $self;
}
   
sub filter {
    my ($self, $text) = @_;
    
    utf8::decode($text);
    
    return $text;
}

1;

__END__