Commit | Line | Data |
5ab21903 |
1 | package TestAppEncoding::Controller::Root; |
2 | use strict; |
3 | use warnings; |
4 | use base 'Catalyst::Controller'; |
5 | use Test::More; |
6 | |
7 | __PACKAGE__->config->{namespace} = ''; |
8 | |
9 | sub binary : Local { |
10 | my ($self, $c) = @_; |
efcb1ae7 |
11 | $c->res->body(do { |
12 | open(my $fh, '<', $c->path_to('..', '..', 'catalyst_130pix.gif')) or die $!; |
13 | binmode($fh); |
14 | local $/ = undef; <$fh>; |
15 | }); |
5ab21903 |
16 | } |
17 | |
18 | sub binary_utf8 : Local { |
19 | my ($self, $c) = @_; |
20 | $c->forward('binary'); |
21 | my $str = $c->res->body; |
22 | utf8::upgrade($str); |
23 | ok utf8::is_utf8($str), 'Body is variable width encoded string'; |
24 | $c->res->body($str); |
25 | } |
26 | |
d9669e44 |
27 | # called by t/aggregate/catalyst_test_utf8.t |
28 | sub utf8_non_ascii_content : Local { |
29 | use utf8; |
30 | my ($self, $c) = @_; |
31 | |
32 | my $str = 'ʇsʎlɐʇɐɔ'; # 'catalyst' flipped at http://www.revfad.com/flip.html |
33 | ok utf8::is_utf8($str), '$str is in UTF8 internally'; |
34 | |
35 | # encode $str into a sequence of octets and turn off the UTF-8 flag, so that |
36 | # we don't get the 'Wide character in syswrite' error in Catalyst::Engine |
37 | utf8::encode($str); |
38 | ok !utf8::is_utf8($str), '$str is a sequence of octets (byte string)'; |
39 | |
40 | $c->res->body($str); |
41 | } |
42 | |
43 | |
5ab21903 |
44 | sub end : Private { |
45 | my ($self,$c) = @_; |
46 | } |
47 | |
48 | 1; |