NAME

Egg::Plugin::Encode - Conversion function of character.

SYNOPSIS

use Egg qw/ Encode /;

my $utf8= $e->utf_conv($text);
my $sjis= $e->sjis_conv($text);
my $euc = $e->euc_conv($text);

DESCRIPTION

Plugin that offers method of converting character-code.

The character-code is converted with Jcode.

The supported character-code is 'euc', 'sjis', 'utf8'.

Please make the 'create_encode' method in the project, and return the object that does the code conversion from the method when converting it excluding Jcode.

sub create_encode {
   AnyComvert->new;
}

It sets it up so that all the input received with Egg::Request is united by the character-code when 'character_in' is defined by the configuration of Egg.

If it wants to treat the code not supported by this plugin, the code conversion can be done in that making the method in which '[code_name]_conv' in the project. And, when the [code_name] is set to 'character_in', the input united by a target code comes to be received.

sub anyname_conv {
  shift->encode->set(@_)->anyname;
}

# Egg configuration.

character_in => 'anyname',

METHODS

encode

The object obtained by the 'create_encode' method is returned.

my $conv_text= $e->encode->set(\$text)->utf8;

create_encode

The object to convert the character-code is returned.

Jcode is restored in default.

If the object that treats the character-code is changed, this method is overwrited as a controller etc.

utf8_conv ([TEXT])

The character-code is converted into utf8.

my $utf8= $e->utf_conv(\$text);

sjis_conv ([TEXT]);

The character-code is converted into Shift_JIS.

my $sjis= $e->sjis_conv(\$text);

euc_conv ([TEXT]);

The character-code is converted into EUC-JP.

my $euc= $e->euc_conv(\$text);

BUGS

Jcode.pm is used and note the point that is always utf8 about the content, please if you do not receive the conversion result when the character to be converted into the method of *_ conv is passed by the SCALAR reference though it is not a translation of bug. This is because of being internally processed with utf8 in the specification of Jcode.

my $text= 'test'; # For shift_jis.
$e->euc_conv(\$text);        # The content of $text is utf8.
$text= $e->euc_conv(\$text); # The content of $text is euc.

$e->utf8_conv(\$text);       # This is untouched utf8.

Perhaps, I think that it is a peculiar problem when Jcode operates as Wrapper of Encode module.

SEE ALSO

Egg::Release, Egg::Request, Jcode,

AUTHOR

Masatoshi Mizuno <lushe@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2008 Bee Flag, Corp. <http://egg.bomcity.com/>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.