line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#-*- perl -*- |
2
|
|
|
|
|
|
|
#-*- encoding: utf-8 -*- |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package MIME::Charset::UTF; |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
57
|
|
7
|
2
|
|
|
2
|
|
9
|
use Carp qw(croak); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
84
|
|
8
|
2
|
|
|
2
|
|
9
|
use Encode::Encoding; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
40
|
|
9
|
2
|
|
|
2
|
|
7
|
use vars qw(@ISA $VERSION); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
828
|
|
10
|
|
|
|
|
|
|
@ISA = qw(Encode::Encoding); |
11
|
|
|
|
|
|
|
$VERSION = '1.010'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
__PACKAGE__->Define('x-utf16auto'); |
14
|
|
|
|
|
|
|
__PACKAGE__->Define('x-utf32auto'); |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
0
|
1
|
0
|
sub perlio_ok { 0 } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub decode { |
19
|
6
|
|
|
6
|
1
|
10
|
my ($self, $octets, $check) = @_; |
20
|
|
|
|
|
|
|
|
21
|
6
|
100
|
|
|
|
16
|
if ($self->name =~ /16/) { |
|
|
50
|
|
|
|
|
|
22
|
3
|
100
|
100
|
|
|
24
|
if ($octets =~ /\A\xFE\xFF/ or $octets =~ /\A\xFF\xFE/) { |
23
|
2
|
|
|
|
|
6
|
return Encode::find_encoding('UTF-16')->decode($_[1], $_[2]); |
24
|
|
|
|
|
|
|
} else { |
25
|
1
|
|
|
|
|
2
|
return Encode::find_encoding('UTF-16BE')->decode($_[1], $_[2]); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} elsif ($self->name =~ /32/) { |
28
|
3
|
100
|
100
|
|
|
32
|
if ($octets =~ /\A\0\0\xFE\xFF/ or $octets =~ /\A\xFF\xFE\0\0/) { |
29
|
2
|
|
|
|
|
6
|
return Encode::find_encoding('UTF-32')->decode($_[1], $_[2]); |
30
|
|
|
|
|
|
|
} else { |
31
|
1
|
|
|
|
|
5
|
return Encode::find_encoding('UTF-32BE')->decode($_[1], $_[2]); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} else { |
34
|
0
|
|
|
|
|
0
|
croak 'bug in logic. Ask developer'; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub encode { |
39
|
2
|
|
|
2
|
1
|
3
|
my $self = $_[0]; |
40
|
|
|
|
|
|
|
|
41
|
2
|
100
|
|
|
|
4
|
if ($self->name =~ /16/) { |
|
|
50
|
|
|
|
|
|
42
|
1
|
|
|
|
|
8
|
return Encode::find_encoding('UTF-16')->encode($_[1], $_[2]); |
43
|
|
|
|
|
|
|
} elsif ($self->name =~ /32/) { |
44
|
1
|
|
|
|
|
13
|
return Encode::find_encoding('UTF-32')->encode($_[1], $_[2]); |
45
|
|
|
|
|
|
|
} else { |
46
|
0
|
|
|
|
|
|
croak 'bug in logic. Ask developer'; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |