| 1 | package MIME::Lite::TT::Japanese; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | $VERSION = '0.08'; | |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use base qw(MIME::Lite::TT); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Jcode; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use DateTime::Format::Mail; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | sub _after_process { | ||||||||||||||||||||||||||
|
Subroutine
_after_process: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | my $class = shift; | |||||||||||||||||||||||||||
| 12 | 1 | 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 | $options{Subject} = encode_header( $options{Subject}, $options{Icode}); | |||||||||||||||||||||||||||
| 20 | 1 | $options{From} = encode_header( $options{From}, $options{Icode}); | |||||||||||||||||||||||||||
| 21 | 1 | $options{Data} = encode_body( $options{Data}, $options{Icode}, $options{LineWidth} ); | |||||||||||||||||||||||||||
| 22 | 1 | delete $options{LineWidth}; | |||||||||||||||||||||||||||
| 23 | 1 | return %options; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 2 | ▶ | sub encode_header { | ||||||||||||||||||||||||||
|
Subroutine
encode_header: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 2 | my ($str, $icode) = @_; | |||||||||||||||||||||||||||
| 28 | 2 | $str = remove_utf8_flag($str); | |||||||||||||||||||||||||||
| 29 | 2 | ▶ | return Jcode->new($str, $icode || guess_encoding($str) )->mime_encode; | ||||||||||||||||||||||||||
|
Condition33%1/3
$icode || guess_encoding($str)
MC/DC0%0/2
$icode || guess_encoding($str)
$icode
guess_encoding($str)
Truth table33%1/3
A || B
A= $icodeB= guess_encoding($str)
| |||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 1 | ▶ | sub encode_body { | ||||||||||||||||||||||||||
|
Subroutine
encode_body: called CC=3 SCAR=12.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | 1 | my ($str, $icode, $line_width) = @_; | |||||||||||||||||||||||||||
| 34 | 1 | $str = remove_utf8_flag($str); | |||||||||||||||||||||||||||
| 35 | 1 | $str =~ s/\x0D\x0A/\n/g; | |||||||||||||||||||||||||||
| 36 | 1 | $str =~ tr/\r/\n/; | |||||||||||||||||||||||||||
| 37 | 1 | ▶ | my $encoding = $icode || guess_encoding($str); | ||||||||||||||||||||||||||
|
Condition33%1/3
$icode || guess_encoding($str)
MC/DC0%0/2
$icode || guess_encoding($str)
$icode
guess_encoding($str)
Truth table33%1/3
A || B
A= $icodeB= guess_encoding($str)
| |||||||||||||||||||||||||||||
| 38 | 1 | ▶ | unless ( $line_width eq '0') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | return join "\n", map { | ||||||||||||||||||||||||||||
| 40 | 0 | Jcode->new($_, $encoding)->jfold($line_width)->jis | |||||||||||||||||||||||||||
| 41 | } split /\n/, $str; | ||||||||||||||||||||||||||||
| 42 | } else { | ||||||||||||||||||||||||||||
| 43 | 1 | return Jcode->new($str, $encoding )->jis; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub guess_encoding { | ||||||||||||||||||||||||||
|
Subroutine
guess_encoding: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 48 | 0 | my ($str) = @_; | |||||||||||||||||||||||||||
| 49 | 0 | ▶ | my $enc = Jcode::getcode($str) || 'euc'; | ||||||||||||||||||||||||||
|
Condition0%0/2
Jcode::getcode($str) || 'euc'
MC/DC0%0/1
Jcode::getcode($str) || 'euc'
Jcode::getcode($str)
Truth table0%0/2
A
A= Jcode::getcode($str)
| |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | $enc = 'euc' if $enc eq 'ascii' || $enc eq 'binary'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$enc eq "ascii" or $enc eq "binary"
MC/DC0%0/2
$enc eq "ascii" or $enc eq "binary"
$enc eq "ascii"
$enc eq "binary"
Truth table0%0/3
A or B
A= $enc eq "ascii"B= $enc eq "binary"
| |||||||||||||||||||||||||||||
| 51 | 0 | return $enc; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 3 | ▶ | sub remove_utf8_flag { pack 'C0A*', $_[0] } | ||||||||||||||||||||||||||
|
Subroutine
remove_utf8_flag: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 2 | 1; | |||||||||||||||||||||||||||
| 57 | __END__ | ||||||||||||||||||||||||||||