
CatalystX::Usul::Encoding - Create additional methods for different encodings

$Revision: 1181 $

use parent qw(CatalystX::Usul::Encoding);
__PACKAGE__->mk_encoding_methods( qw(get_req_array get_req_value) );
sub get_req_array {
my ($self, $req, $field) = @_; my $value = $req->params->{ $field };
$value = defined $value ? $value : [];
return (is_arrayref $value) ? $value : [ $value ];
}
sub get_req_value {
my ($self, $req, $field) = @_; my $value = $req->params->{ $field };
return (is_arrayref $value) ? $value->[ 0 ] : $value;
}
# The standard calls are
$array = $self->get_req_array( $c->req, $field );
$value = $self->get_req_value( $c->req, $field );
# but now we can call these methods also
$array = $self->get_req_array_ascii_encoding( $c->req, $field );
$array = $self->get_req_array_iso_8859_1_encoding( $c->req, $field );
$array = $self->get_req_array_utf_8_encoding( $c->req, $field );
$array = $self->get_req_array_guess_encoding( $c->req, $field );
$value = $self->get_req_value_ascii_encoding( $c->req, $field );
$value = $self->get_req_value_iso_8859_1_encoding( $c->req, $field );
$value = $self->get_req_value_utf_8_encoding( $c->req, $field );
$value = $self->get_req_value_guess_encoding( $c->req, $field );

For each input method defined in your class "mk_encoding_methods" defines additional methods; my_input_method_utf_8_encoding and my_input_method_guess_encoding for example

Takes a list of method names in the calling package. For each of these a set of new methods are defined in the calling package. The method set is defined by the list of values in the $ENCODINGS package variable. Each of these newly defined methods calls _decode_data with a different encoding name
Decodes the data passed using the given encoding name. Can handle both scalars and array refs but not hashes
If you really don't know what the source encoding is then this method will use Encode::Guess to determine the encoding. If successful calls _decode_data to get the job done
Takes an encoding name and converts it to a private method name

None

None


There are no known incompatibilities in this module

There are no known bugs in this module. Please report problems to the address below. Patches are welcome

Peter Flanigan, <Support at RoxSoft.co.uk>

Copyright (c) 2011 Peter Flanigan. All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic
This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE