line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: /mirror/coderepos/lang/perl/Encode-StdIO/trunk/lib/Encode/StdIO.pm 50483 2008-04-15T14:45:42.926236Z daisuke $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Encode::StdIO; |
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
40
|
|
5
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
6
|
1
|
|
|
1
|
|
31
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
268
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.00001'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub import |
10
|
|
|
|
|
|
|
{ |
11
|
1
|
|
|
1
|
|
2
|
my $class = shift; |
12
|
1
|
|
|
|
|
2
|
my %args = @_; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
|
|
4
|
my $encoding = $class->find_encoding(%args); |
15
|
1
|
|
|
1
|
|
6
|
binmode(STDOUT, ":encoding($encoding)"); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
26
|
|
16
|
1
|
|
|
|
|
21743
|
binmode(STDERR, ":encoding($encoding)"); |
17
|
1
|
|
|
|
|
32
|
binmode(STDIN, ":encoding($encoding)"); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub find_encoding |
21
|
|
|
|
|
|
|
{ |
22
|
1
|
|
|
1
|
0
|
2
|
my $class = shift; |
23
|
1
|
|
|
|
|
2
|
my %args = @_; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
1
|
my $encoding = $args{encoding}; |
26
|
1
|
50
|
|
|
|
4
|
if (! $encoding) { |
27
|
1
|
|
|
|
|
1
|
eval { |
28
|
1
|
|
|
|
|
838
|
require Term::Encoding; |
29
|
1
|
|
|
|
|
769
|
$encoding = Term::Encoding::get_encoding(); |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
} |
32
|
1
|
|
50
|
|
|
2236
|
$encoding ||= "utf-8"; |
33
|
1
|
|
|
|
|
3
|
return $encoding; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__END__ |