| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Test::Stream::Plugin::UTF8; | 
| 2 | 95 |  |  | 95 |  | 1105 | use strict; | 
|  | 95 |  |  |  |  | 202 |  | 
|  | 95 |  |  |  |  | 2494 |  | 
| 3 | 95 |  |  | 95 |  | 491 | use warnings; | 
|  | 95 |  |  |  |  | 189 |  | 
|  | 95 |  |  |  |  | 2516 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 95 |  |  | 95 |  | 511 | use Test::Stream::Sync; | 
|  | 95 |  |  |  |  | 184 |  | 
|  | 95 |  |  |  |  | 1956 |  | 
| 6 | 95 |  |  | 95 |  | 514 | use Test::Stream::Plugin; | 
|  | 95 |  |  |  |  | 187 |  | 
|  | 95 |  |  |  |  | 660 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | sub load_ts_plugin { | 
| 9 | 113 |  |  | 113 | 0 | 300 | my $class = shift; | 
| 10 | 113 |  |  |  |  | 258 | my ($caller) = @_; | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | # Load and import UTF8 into the caller. | 
| 13 | 113 |  |  |  |  | 661 | require utf8; | 
| 14 | 113 |  |  |  |  | 701 | utf8->import; | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | # Set STDERR and STDOUT | 
| 17 | 113 |  |  |  |  | 962 | binmode(STDERR, ':utf8'); | 
| 18 | 113 |  |  |  |  | 359 | binmode(STDOUT, ':utf8'); | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | # Set the output formatters to use utf8 | 
| 21 |  |  |  |  |  |  | Test::Stream::Sync->post_load(sub { | 
| 22 | 111 |  |  | 111 |  | 500 | my $stack = Test::Stream::Sync->stack; | 
| 23 | 111 |  |  |  |  | 648 | $stack->top; # Make sure we have at least 1 hub | 
| 24 |  |  |  |  |  |  |  | 
| 25 | 111 |  |  |  |  | 216 | my $warned = 0; | 
| 26 | 111 |  |  |  |  | 620 | for my $hub ($stack->all) { | 
| 27 | 115 |  | 100 |  |  | 548 | my $format = $hub->format || next; | 
| 28 |  |  |  |  |  |  |  | 
| 29 | 111 | 50 |  |  |  | 729 | unless ($format->can('encoding')) { | 
| 30 | 0 | 0 |  |  |  | 0 | warn "Could not apply UTF8 to unknown formatter ($format) at $caller->[1] line $caller->[2].\n" unless $warned++; | 
| 31 | 0 |  |  |  |  | 0 | next; | 
| 32 |  |  |  |  |  |  | } | 
| 33 |  |  |  |  |  |  |  | 
| 34 | 111 |  |  |  |  | 519 | $format->encoding('utf8'); | 
| 35 |  |  |  |  |  |  | } | 
| 36 | 113 |  |  |  |  | 1142 | }); | 
| 37 |  |  |  |  |  |  | } | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | 1; | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | __END__ |