Name
CGI::Application::Plugin::Eparam
SYNOPSIS
package WebApp
use Jcode;# ¤³¤Î¾ use Encode ¤¹¤ë¤«¡¢¼«Á°¤Ç $CGI::Application::Plugin::Eparam::econv = sub { ... } ¤È¡¢ÊÑ´¹¥í¥¸¥Ã¥¯¤ò¼ÂÁõ¤¹¤ë
use CGI::Application::Plugin::Eparam;
sub cgiapp_init {
$CGI::Application::Plugin::Eparam::icode = 'sjis'; # ÆþÎϤµ¤ì¤ëʸ»ú¥³¡¼¥É
$CGI::Application::Plugin::Eparam::ocode = 'euc-jp'; # ÊÑ´¹¤·¤¿¤¤Ê¸»ú¥³¡¼¥É
}
package WebApp::Pages::Public
sub page1 {
my $self = shift;
my $data = $self->eparam('data'); # ÊÑ´¹¸å¤ÎÃÍ
my $natural_data = $self->query->param('data'); # ÊÑ´¹Á°¤ÎÃÍ
}
Example
Get Value
package WebApp::Pages::Public
sub page1 {
my $self = shift;
my $data = $self->eparam('data');
my $natural_data = $self->query->param('data');
}
in Application
package WebApp
use Jcode;
use CGI::Application::Plugin::Eparam;
sub cgiapp_init {
$CGI::Application::Plugin::Eparam::icode = 'sjis';
$CGI::Application::Plugin::Eparam::ocode = 'euc-jp';
}
in SubClass
package WebApp::Pages::Public
sub setup {
$CGI::Application::Plugin::Eparam::icode = 'sjis';
$CGI::Application::Plugin::Eparam::ocode = 'euc-jp';
}
package WebApp::Pages::Admin
sub setup {
$CGI::Application::Plugin::Eparam::icode = 'euc-jp';
$CGI::Application::Plugin::Eparam::ocode = 'euc-jp';
}
in Method
package WebApp::Pages::User::Mailform
sub mailform {
# ¤³¤Î¾ì¹çÊÑ´¹¤Ï¹Ô¤ï¤ì¤Þ¤»¤ó
$CGI::Application::Plugin::Eparam::icode = 'jis';
$CGI::Application::Plugin::Eparam::ocode = 'jis';
# ¥á¡¼¥ë¤Î·ï̾¤Ë¤·¤¿¤¤Éôʬ¤À¤±¤òjis¤ÇÆÀ¤ë¤è¤¦¤Ê»ö¤¬½ÐÍè¤Þ¤¹
$CGI::Application::Plugin::Eparam::icode = 'sjis';
$CGI::Application::Plugin::Eparam::ocode = 'jis';
}
in Part
package Myapplication::Pages::User::Mailform
sub mailform {
# °ì»þŪ¤ËÀßÄê¤òÊѹ¹¤¹¤ë»ö¤¬½ÐÍè¤Þ¤¹
$CGI::Application::Plugin::Eparam::temp_icode = 'sjis';
$CGI::Application::Plugin::Eparam::temp_ocode = 'jis';
my $val_jis = $self->eparam('val');
# undef¤Ç¸µ¤ËÌ᤻¤Þ¤¹
undef $CGI::Application::Plugin::Eparam::temp_icode;
undef $CGI::Application::Plugin::Eparam::temp_ocode;
my $val_sjis = $self->eparam('val');
}
Convert Logic Customize
# ¼«Ê¬¤ÇÊÑ´¹¥í¥¸¥Ã¥¯¤òÁȤà»ö¤¬½ÐÍè¤Þ¤¹
$CGI::Application::Plugin::Eparam::econv = sub {
my $textref = shift;
my $ocode = shift; # output character code
my $icode = shift; # input character code
# some logic
Encode::from_to($$textref, 'Guess', $ocode);
};
# temp_¤ò»È¤¦¤È°ì»þŪ¤Ê¤â¤Î¤Ë¤Ê¤ê¤Þ¤¹
$CGI::Application::Plugin::Eparam::temp_econv = sub {
my $textref = shift;
my $ocode = shift; # output character code
my $icode = shift; # input character code
# some logic
Encode::from_to($$textref, 'Guess', $ocode);
};
# undef¤Ç¸µ¤ËÌᤷ¤Þ¤¹
undef $CGI::Application::Plugin::Eparam::temp_econv;
SEE ALSO
AUTHOR
Shinichiro Aska
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 10:
Non-ASCII character seen before =encoding in '¤³¤Î¾'. Assuming CP1252