line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MIME::Lite::TT::Japanese; |
2
|
2
|
|
|
2
|
|
96294
|
use strict; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
96
|
|
3
|
2
|
|
|
2
|
|
12
|
use vars qw($VERSION); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
190
|
|
4
|
|
|
|
|
|
|
$VERSION = '0.08'; |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
385
|
use base qw(MIME::Lite::TT); |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
3501
|
|
7
|
2
|
|
|
2
|
|
228538
|
use Jcode; |
|
2
|
|
|
|
|
136653
|
|
|
2
|
|
|
|
|
218
|
|
8
|
2
|
|
|
2
|
|
3381
|
use DateTime::Format::Mail; |
|
2
|
|
|
|
|
497533
|
|
|
2
|
|
|
|
|
1047
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub _after_process { |
11
|
1
|
|
|
1
|
|
86210
|
my $class = shift; |
12
|
1
|
|
|
|
|
13
|
my %options = ( |
13
|
|
|
|
|
|
|
Type => 'text/plain; charset=iso-2022-jp', |
14
|
|
|
|
|
|
|
Encoding => '7bit', |
15
|
|
|
|
|
|
|
Datestamp => 0, |
16
|
|
|
|
|
|
|
Date => DateTime::Format::Mail->format_datetime( DateTime->now->set_time_zone('Asia/Tokyo') ), |
17
|
|
|
|
|
|
|
@_, |
18
|
|
|
|
|
|
|
); |
19
|
1
|
|
|
|
|
22195
|
$options{Subject} = encode_header( $options{Subject}, $options{Icode}); |
20
|
1
|
|
|
|
|
731
|
$options{From} = encode_header( $options{From}, $options{Icode}); |
21
|
1
|
|
|
|
|
304
|
$options{Data} = encode_body( $options{Data}, $options{Icode}, $options{LineWidth} ); |
22
|
1
|
|
|
|
|
102
|
delete $options{LineWidth}; |
23
|
1
|
|
|
|
|
17
|
return %options; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub encode_header { |
27
|
2
|
|
|
2
|
0
|
6
|
my ($str, $icode) = @_; |
28
|
2
|
|
|
|
|
8
|
$str = remove_utf8_flag($str); |
29
|
2
|
|
33
|
|
|
81
|
return Jcode->new($str, $icode || guess_encoding($str) )->mime_encode; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub encode_body { |
33
|
1
|
|
|
1
|
0
|
4
|
my ($str, $icode, $line_width) = @_; |
34
|
1
|
|
|
|
|
2
|
$str = remove_utf8_flag($str); |
35
|
1
|
|
|
|
|
4
|
$str =~ s/\x0D\x0A/\n/g; |
36
|
1
|
|
|
|
|
2
|
$str =~ tr/\r/\n/; |
37
|
1
|
|
33
|
|
|
5
|
my $encoding = $icode || guess_encoding($str); |
38
|
1
|
50
|
|
|
|
5
|
unless ( $line_width eq '0') { |
39
|
0
|
|
|
|
|
0
|
return join "\n", map { |
40
|
0
|
|
|
|
|
0
|
Jcode->new($_, $encoding)->jfold($line_width)->jis |
41
|
|
|
|
|
|
|
} split /\n/, $str; |
42
|
|
|
|
|
|
|
} else { |
43
|
1
|
|
|
|
|
26
|
return Jcode->new($str, $encoding )->jis; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub guess_encoding { |
48
|
0
|
|
|
0
|
0
|
0
|
my ($str) = @_; |
49
|
0
|
|
0
|
|
|
0
|
my $enc = Jcode::getcode($str) || 'euc'; |
50
|
0
|
0
|
0
|
|
|
0
|
$enc = 'euc' if $enc eq 'ascii' || $enc eq 'binary'; |
51
|
0
|
|
|
|
|
0
|
return $enc; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
3
|
|
|
3
|
0
|
17
|
sub remove_utf8_flag { pack 'C0A*', $_[0] } |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
__END__ |