| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Config::Maker::Encode; |
|
2
|
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
51
|
use utf8; |
|
|
9
|
|
|
|
|
16
|
|
|
|
9
|
|
|
|
|
50
|
|
|
4
|
9
|
|
|
9
|
|
288
|
use warnings; |
|
|
9
|
|
|
|
|
15
|
|
|
|
9
|
|
|
|
|
275
|
|
|
5
|
9
|
|
|
9
|
|
45
|
use strict; |
|
|
9
|
|
|
|
|
16
|
|
|
|
9
|
|
|
|
|
293
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
43
|
use Carp; |
|
|
9
|
|
|
|
|
16
|
|
|
|
9
|
|
|
|
|
505
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
9
|
|
|
9
|
|
45
|
use Exporter; |
|
|
9
|
|
|
|
|
14
|
|
|
|
9
|
|
|
|
|
8184
|
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
11
|
|
|
|
|
|
|
our @EXPORT = qw(encode decode encmode $utf8); |
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = @EXPORT; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub encode($$;$); |
|
15
|
|
|
|
|
|
|
sub decode($$;$); |
|
16
|
|
|
|
|
|
|
sub encmode(*$); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $utf8; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _encode_only_system($$;$) { |
|
21
|
0
|
|
|
0
|
|
0
|
my ($enc, $text, $check) = @_; |
|
22
|
0
|
0
|
|
|
|
0
|
unless($enc eq 'system') { |
|
23
|
0
|
0
|
|
|
|
0
|
if($check == 1) { |
|
24
|
0
|
|
|
|
|
0
|
croak "Encoding not available. Can't convert encoding $enc"; |
|
25
|
|
|
|
|
|
|
} else { |
|
26
|
0
|
|
|
|
|
0
|
carp "Encoding not available. Can't convert encoding $enc"; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
} |
|
29
|
0
|
|
|
|
|
0
|
return $text; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _binmode_only_system(*$) { |
|
33
|
0
|
|
|
0
|
|
0
|
my ($handle, $enc) = @_; |
|
34
|
0
|
0
|
|
|
|
0
|
unless($enc eq 'system') { |
|
35
|
0
|
|
|
|
|
0
|
carp "Encoding not available. Can't set encoding to $enc"; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _binmode_encoding(*$) { |
|
40
|
45
|
|
|
45
|
|
101
|
my ($handle, $enc) = @_; |
|
41
|
45
|
|
|
|
|
1187
|
binmode $handle, ":encoding($enc)"; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
eval { |
|
45
|
|
|
|
|
|
|
require I18N::Langinfo; |
|
46
|
|
|
|
|
|
|
require Encode; |
|
47
|
|
|
|
|
|
|
require Encode::Alias; |
|
48
|
|
|
|
|
|
|
require PerlIO::encoding; |
|
49
|
|
|
|
|
|
|
$::ENCODING = I18N::Langinfo::langinfo(&I18N::Langinfo::CODESET); |
|
50
|
|
|
|
|
|
|
if(!$::ENCODING) { |
|
51
|
|
|
|
|
|
|
$::ENCODING_LOG = "Can't get your locale encoding! Assuming ASCII."; |
|
52
|
|
|
|
|
|
|
Encode::find_encoding($::ENCODING = 'ascii') |
|
53
|
|
|
|
|
|
|
or die "Can't get ascii codec!"; |
|
54
|
|
|
|
|
|
|
} elsif(!Encode::find_encoding($::ENCODING)) { |
|
55
|
|
|
|
|
|
|
$::ENCODING_LOG = "Your locale encoding `$::ENCODING' it's not supported by Encode!"; |
|
56
|
|
|
|
|
|
|
Encode::find_encoding($::ENCODING = 'ascii') |
|
57
|
|
|
|
|
|
|
or die "Can't get ascii codec!"; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
Encode::Alias::define_alias('system' => $::ENCODING); |
|
60
|
|
|
|
|
|
|
}; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
if($@) { # Encoding stuff not available! |
|
63
|
|
|
|
|
|
|
undef $::ENCODING; |
|
64
|
|
|
|
|
|
|
*encode = \&_encode_only_system; |
|
65
|
|
|
|
|
|
|
*decode = \&_encode_only_system; |
|
66
|
|
|
|
|
|
|
*encmode = \&_binmode_only_system; |
|
67
|
|
|
|
|
|
|
$utf8 = ''; |
|
68
|
|
|
|
|
|
|
} else { # Wow! Encoding is available! |
|
69
|
|
|
|
|
|
|
*encode = \&Encode::encode; |
|
70
|
|
|
|
|
|
|
*decode = \&Encode::decode; |
|
71
|
|
|
|
|
|
|
*encmode = \&_binmode_encoding; |
|
72
|
|
|
|
|
|
|
$utf8 = ':utf8'; |
|
73
|
|
|
|
|
|
|
binmode STDERR, ':encoding(system)'; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |