Catalyst-Plugin-Unicode
view release on metacpan or search on metacpan
Revision history for Perl extension Catalyst::Plugin::Unicode
0.93 Wed Mar 17 22:35:00 GMT 2010
- Make the documentation be phrased much more strongly
about how this is not the preferred unicode module.
0.92 Sun Oct 4 18:30:00 GMT 2009
- Add documentation note that you probably want to use
Catalyst::Plugin::Unicode::Encoding
0.91 Sat Apr 18 23:47:00 GMT 2009
- Fix manifest failure
0.9 Sat Apr 18 11:47:00 GMT 2009
- Makefile.PL: build_requires => test_requires (RT #37960)
t/lib/TestApp/Controller/Root.pm view on Meta::CPAN
__PACKAGE__->config(namespace => q{});
use base 'Catalyst::Controller';
# your actions replace this one
sub main :Path {
$_[1]->res->body('<h1>It works</h1>')
}
sub unicode :Local {
my ($self, $c) = @_;
my $data = "ã»ã"; # hoge!
$c->response->body($data); # should be decoded
}
sub not_unicode :Local {
my ($self, $c) = @_;
my $data = "\x{1234}\x{5678}";
utf8::encode($data); # DO NOT WANT unicode
$c->response->body($data); # just some octets
}
sub file :Local {
my ($self, $c) = @_;
close *STDERR; # i am evil.
$c->response->body($main::TEST_FILE); # filehandle from test file
}
1;
t/live-test.t view on Meta::CPAN
our $TEST_FILE = IO::Scalar->new(\"this is a test");
sub IO::Scalar::FILENO { -1 }; # needed?
# a live test against TestApp, the test application
use Test::WWW::Mechanize::Catalyst 'TestApp';
my $mech = Test::WWW::Mechanize::Catalyst->new;
$mech->get_ok('http://localhost/', 'get main page');
$mech->content_like(qr/it works/i, 'see if it has our text');
{
$mech->get_ok('http://localhost/unicode', 'get unicode');
my $content = $mech->content;
ok(!utf8::is_utf8($content), 'not utf8');
utf8::decode($content);
ok(utf8::is_utf8($content), 'now its utf8');
like $content, qr/ã»ã/, 'content contains hoge';
}
{
$mech->get_ok('http://localhost/not_unicode', 'get bytes');
my $content = $mech->content;
ok(!utf8::is_utf8($content), 'not utf8');
my $regex = "\x{1234}\x{5678}";
utf8::encode($regex);
like $content, qr/$regex/, 'got 1234 5678';
}
{
$mech->get_ok('http://localhost/file', 'get file');
$mech->content_like(qr/this is a test/, 'got filehandle contents');
( run in 0.266 second using v1.01-cache-2.11-cpan-88abd93f124 )