Catalyst::Plugin::Unicode の中身
[Catalyst]
フォーム入力時、UTF8フラグをつける(utf8::decode)
HTML出力時、UTF8フラグを全て落とす(utf8::encode)
package Catalyst::Plugin::Unicode;
use strict;
our $VERSION = '0.8';
sub finalize {
my $c = shift;
if ( $c->response->{body} && utf8::is_utf8($c->response->{body}) ){
utf8::encode( $c->response->{body} );
}
return $c->NEXT::finalize;
}
sub prepare_parameters {
my $c = shift;
$c->NEXT::prepare_parameters;
for my $value ( values %{ $c->request->{parameters} } ) {
if ( ref $value && ref $value ne 'ARRAY' ) {
next;
}
utf8::decode($_) for ( ref($value) ? @{$value} : $value );
}
}
1;