File: Root.pm

package info (click to toggle)
libcatalyst-engine-apache-perl 1.16-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch, wheezy
  • size: 1,040 kB
  • ctags: 667
  • sloc: perl: 6,344; makefile: 2
file content (48 lines) | stat: -rw-r--r-- 1,231 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package TestAppEncoding::Controller::Root;
use strict;
use warnings;
use base 'Catalyst::Controller';
use Test::More;

__PACKAGE__->config->{namespace} = '';

sub binary : Local {
    my ($self, $c) = @_;
    $c->res->body(do { 
        open(my $fh, '<', $c->path_to('..', '..', 'catalyst_130pix.gif')) or die $!; 
        binmode($fh); 
        local $/ = undef; <$fh>;
    });
}

sub binary_utf8 : Local {
    my ($self, $c) = @_;
    $c->forward('binary');
    my $str = $c->res->body;
    utf8::upgrade($str);
    ok utf8::is_utf8($str), 'Body is variable width encoded string';
    $c->res->body($str);
}

# called by t/aggregate/catalyst_test_utf8.t
sub utf8_non_ascii_content : Local {
    use utf8;
    my ($self, $c) = @_;
    
    my $str = 'ʇsʎlɐʇɐɔ';  # 'catalyst' flipped at http://www.revfad.com/flip.html
    ok utf8::is_utf8($str), '$str is in UTF8 internally';
    
    # encode $str into a sequence of octets and turn off the UTF-8 flag, so that
    # we don't get the 'Wide character in syswrite' error in Catalyst::Engine
    utf8::encode($str);
    ok !utf8::is_utf8($str), '$str is a sequence of octets (byte string)';
    
    $c->res->body($str);
}


sub end : Private {
    my ($self,$c) = @_;
}

1;