NAME

CGI::ConvertParam - CGI::param()¥á¥½¥Ã¥É¤Ø¤Î´Á»ú¥³¡¼¥ÉÊÑ´¹¥Õ¥Ã¥¯¤ÎÄɲÃ

SYNOPSIS

package CGI::ConvertParam::OngetUTF8;
use base 'CGI::ConvertParam';
use Jcode;

sub do_convert_on_get
{
    my $self = shift;
    my $parameter_value = shift;
    return Jcode->new($parameter_value)->utf8;
}
1;

package client;
use CGI;
use CGI::ConvertParam::OngetUTF8;

$query = CGI::ConvertParam::OngetUTF8->new(CGI->new);
print $query->param('parameter_foo');

DESCRIPTION

CGI::ConvertParam ¤Ï CGI.pm ¤Î param() ¥á¥½¥Ã¥É¤ò¥Ñ¥é¡¼¥á¡¼¥¿¤Î°ì³ç¤·¤¿Ê¸»ú¥³¡¼¥ÉÊÑ´¹¤ä¼èÆÀ»þ¤ÎÊÑ´¹¤â¤·¤¯¤ÏÀßÄê»þ¤ÎÊÑ´¹¤ò¹Ô¤¨¤ë¤è¤¦¤Ë³ÈÄ¥¤·¤Þ¤¹¡£Decorator¥Ñ¥¿¡¼¥ó¤Ë¤è¤Ã¤Æ³ÈÄ¥¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£

EXAMPLE

Á´¥Ñ¥é¥á¡¼¥¿¤ò EUC-JP ¤ËÊÑ´¹¤¹¤ë¡£

package CGI::ConvertParam::EUC;
use base 'CGI::ConvertParam';
use Jcode;

sub initialize
{
    my $self = shift;
    $self->convert_all_param;
}

sub do_convert_all
{
    my $self    = shift;
    my $strings = shift;
    return Jcode->new($strings)->euc;
}
1;

package main;
use CGI;
use CGI::ConvertParam::EUC;
my $query = CGI::ConvertParam::EUC->new(CGI->new);
print 'Name(EUC-JP):', $query->param('NAME');

Ãͤò¥»¥Ã¥È¤¹¤ëºÝ¤Ë Shift-JIS ¤ØÊÑ´¹¤¹¤ë¡£

package CGI::ConvertParam::OnsetShiftJIS;
use base 'CGI::ConvertParam';
use Jcode;

sub do_convert_on_set
{
    my $self    = shift;
    my $strings = shift;
    return Jcode->new($strings)->sjis;
}
1;


package main;
use CGI;
use CGI::ConvertParam::OnsetShiftJIS;
my $query = CGI::ConvertParam::OnsetShiftJIS->new(CGI->new);
$query->param(NAME => $value);
print 'Name(Shift-JIS):', $query->param('NAME');

Ãͤò¼èÆÀ¤¹¤ëºÝ¤Ë UTF-8 ¤ËÊÑ´¹¤¹¤ë¡£

package CGI::ConvertParam::OngetUTF8;
use base 'CGI::ConvertParam';
use Jcode;

sub do_convert_on_get
{
    my $self    = shift;
    my $strings = shift;
    return Jcode->new($strings)->utf8;
}
1;


package main;
use CGI;
use CGI::ConvertParam::OngetUTF8;
my $query = CGI::ConvertParam::OngetUTF8->new(CGI->new);
$query->param(NAME => $value);
print 'Name(UTF-8):', $query->param('NAME');

METHOD

Class method

new(CGI_OBJECT)

The new() method is the constructor for a CGI::ConvertParam and sub-class. CGI_BOJECT is the reference of the CGI instance. It return a specialized CGI instance.

new() ¥á¥½¥Ã¥É¤Ï CGI::ConvertParam ¤È¤½¤Î¥µ¥Ö¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿¤Ç¤¹¡£CGI_OBJECT ¤Ë CGI¥â¥¸¥å¡¼¥ë¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤òÅϤ¹¤È¡¢³ÈÄ¥¤·¤¿ CGI.pm ¸ß´¹¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£

Instance method

convert_all_param()

convert_all_param() ¥á¥½¥Ã¥É¤ÏÁ´¤Æ¤Î¥Ñ¥é¥á¡¼¥¿¤ËÊÑ´¹½èÍý¤ò¹Ô¤¤¤Þ¤¹¡£

Subclassing and Override methods

CGI::ConvertParam ¤Ï¥µ¥Ö¥¯¥é¥¹¤òºîÀ®¤·¥á¥½¥Ã¥É¤ò¾å½ñ¤­¡Ê¥ª¡¼¥Ð¡¼¥é¥¤¥É¡Ë¤¹¤ë¤³¤È¤Ë¤è¤Ã¤Æ¼ÂÁõ¤ò¹Ô¤¤¤Þ¤¹¡£¾å½ñ¤­¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¥á¥½¥Ã¥É¤Ï°Ê²¼¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤:

initialize()

¤³¤Î¥á¥½¥Ã¥É¤Ï new() ¥³¥ó¥¹¥È¥é¥¯¥¿¤«¤é¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£initialize()¥á¥½¥Ã¥É¤ò¾å½ñ¤­¤¹¤ë¤³¤È¤Ç¥Ñ¥é¥á¡¼¥¿¤ÎÄɲää¥á¥½¥Ã¥É¤Î¸Æ¤Ó½Ð¤·¤ò¹Ô¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£

do_convert_on_set()

¤³¤Î¥á¥½¥Ã¥É¤Ï param('name' => $value) ¤Ê¤É¡¢param() ¥á¥½¥Ã¥É¤ÇÃͤòÀßÄꤹ¤ëÁ°¤Ë¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£

do_convert_on_get()

¤³¤Î¥á¥½¥Ã¥É¤Ï param('name') ¤Ê¤É¡¢param()¥á¥½¥Ã¥É¤ÇÃͤò»²¾È¤¹¤ë¤È¤­¤Ë¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£

do_convert_all_param

¤³¤Î¥á¥½¥Ã¥É¤Ï convert_all_param()¥á¥½¥Ã¥É¤«¤é¸Æ¤Ó½Ð¤µ¤ì¤Þ¤¹¡£

Data-access method

query()

¤³¤Î¥á¥½¥Ã¥É¤Ï³ÈÄ¥¤¹¤ëÁ°¤ÎCGI¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£

SEE ALSO

CGI

AUTHOR

OYAMA Hiroyuki <oyama@crayfish.co.jp> http://perl.infoware.ne.jp/

COPYRIGHT

Copyright(c) 2000, OYAMA Hiroyuki. Japan. All rights reserved.

CGI::ConvertParam class may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 5:

Non-ASCII character seen before =encoding in 'CGI::param()¥á¥½¥Ã¥É¤Ø¤Î´Á»ú¥³¡¼¥ÉÊÑ´¹¥Õ¥Ã¥¯¤ÎÄɲÃ'. Assuming CP1252