line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: /mirror/perl/File-Extract/trunk/lib/File/Extract/Base.pm 4210 2007-10-27T13:43:07.499967Z daisuke $ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Copyright (c) 2005 Daisuke Maki |
4
|
|
|
|
|
|
|
# All rights reserved. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package File::Extract::Base; |
7
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
79
|
|
8
|
2
|
|
|
2
|
|
2664
|
use Encode qw(encode decode FB_PERLQQ); |
|
2
|
|
|
|
|
64763
|
|
|
2
|
|
|
|
|
231
|
|
9
|
2
|
|
|
2
|
|
2244
|
use Encode::Guess; |
|
2
|
|
|
|
|
10312
|
|
|
2
|
|
|
|
|
11
|
|
10
|
2
|
|
|
2
|
|
1424
|
use File::Extract::Result; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
719
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new |
13
|
|
|
|
|
|
|
{ |
14
|
1
|
|
|
1
|
1
|
4
|
my $class = shift; |
15
|
1
|
|
|
|
|
15
|
my %args = @_; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
50
|
|
|
5
|
my $encoding = $args{output_encoding} || 'utf8'; |
18
|
1
|
|
|
|
|
5
|
my @encodings = $args{encodings} ? |
19
|
1
|
50
|
|
|
|
260
|
(ref($args{encodings}) eq 'ARRAY' ? @{$args{encodings}} : $args{encodings}) : (); |
|
|
50
|
|
|
|
|
|
20
|
1
|
|
|
|
|
16
|
return bless { |
21
|
|
|
|
|
|
|
output_encoding => $encoding, |
22
|
|
|
|
|
|
|
encodings => \@encodings |
23
|
|
|
|
|
|
|
}, $class; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
0
|
1
|
0
|
sub mime_type { Carp::croak(__PACKAGE__ . '::mime_type() is not defined') } |
27
|
0
|
|
|
0
|
1
|
0
|
sub extract { Carp::croak(__PACKAGE__ . '::extract() is not defined') } |
28
|
|
|
|
|
|
|
sub recode |
29
|
|
|
|
|
|
|
{ |
30
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
31
|
1
|
|
|
|
|
2
|
my $text = shift; |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
3
|
my $enc = eval { guess_encoding($text, @{$self->{encodings}}) }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
34
|
1
|
50
|
|
|
|
1124
|
ref($enc) or die "Can't guess: $enc"; |
35
|
1
|
|
|
|
|
28
|
return encode($self->{output_encoding}, $enc->decode($text), FB_PERLQQ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |