| 1 | package Encode::IBM::835SOSI; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 1 | $VERSION = '1.01'; | |||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | ▶ | use Encode (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 1 | ▶ | use base qw(Encode::Encoding); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 1 | __PACKAGE__->Define('ibm-835-sosi'); | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 1 | my $base37; | |||||||||||||||||||
| 13 | my $base835; | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | sub decode | ||||||||||||||||||||
| 16 | { | ||||||||||||||||||||
| 17 | 0 | ▶ | my ($obj,$str,$chk) = @_; | ||||||||||||||||||
|
Subroutine
decode: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 0 | ▶ | $base37 ||= Encode::find_encoding('cp37'); | ||||||||||||||||||
|
Condition0%0/3
$base37 ||= &Encode::find_encoding("cp37")
MC/DC0%0/2
$base37 ||= &Encode::find_encoding("cp37")
$base37
&Encode::find_encoding("cp37")
Truth table0%0/3
A ||= B
A= $base37B= &Encode::find_encoding("cp37")
| |||||||||||||||||||||
| 20 | 0 | ▶ | $base835 ||= Encode::find_encoding('ibm-835'); | ||||||||||||||||||
|
Condition0%0/3
$base835 ||= &Encode::find_encoding("ibm-835")
MC/DC0%0/2
$base835 ||= &Encode::find_encoding("ibm-835")
$base835
&Encode::find_encoding("ibm-835")
Truth table0%0/3
A ||= B
A= $base835B= &Encode::find_encoding("ibm-835")
| |||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 0 | my $out; | |||||||||||||||||||
| 23 | 0 | foreach my $chunk (split(/\x0E([^\x0F]*\x0F)/, $str)) { | |||||||||||||||||||
| 24 | 0 | ▶ | if ($chunk =~ /\x0F\z/) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 25 | 0 | chop $chunk; | |||||||||||||||||||
| 26 | 0 | $out .= $base835->decode($chunk); | |||||||||||||||||||
| 27 | } | ||||||||||||||||||||
| 28 | else { | ||||||||||||||||||||
| 29 | 0 | $out .= $base37->decode($chunk); | |||||||||||||||||||
| 30 | } | ||||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | 0 | return $out; | |||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | sub encode | ||||||||||||||||||||
| 36 | { | ||||||||||||||||||||
| 37 | 0 | ▶ | my ($obj,$str,$chk) = @_; | ||||||||||||||||||
|
Subroutine
encode: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 0 | ▶ | $base37 ||= Encode::find_encoding('cp37'); | ||||||||||||||||||
|
Condition0%0/3
$base37 ||= &Encode::find_encoding("cp37")
MC/DC0%0/2
$base37 ||= &Encode::find_encoding("cp37")
$base37
&Encode::find_encoding("cp37")
Truth table0%0/3
A ||= B
A= $base37B= &Encode::find_encoding("cp37")
| |||||||||||||||||||||
| 40 | 0 | ▶ | $base835 ||= Encode::find_encoding('ibm-835'); | ||||||||||||||||||
|
Condition0%0/3
$base835 ||= &Encode::find_encoding("ibm-835")
MC/DC0%0/2
$base835 ||= &Encode::find_encoding("ibm-835")
$base835
&Encode::find_encoding("ibm-835")
Truth table0%0/3
A ||= B
A= $base835B= &Encode::find_encoding("ibm-835")
| |||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 0 | ▶ | if ($str =~ s/^([\x00-\xff]+)//) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 43 | # english | ||||||||||||||||||||
| 44 | 0 | my $sub = $1; | |||||||||||||||||||
| 45 | 0 | return $base37->encode($sub) . $obj->encode($str, $chk); | |||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | elsif ($str =~ s/^([^\x00-\xff]+)//) { | ||||||||||||||||||||
| 48 | # chinese - shift in + shift out | ||||||||||||||||||||
| 49 | 0 | my $sub = $1; | |||||||||||||||||||
| 50 | 0 | return "\x0E".$base835->encode($sub)."\x0F".$obj->encode($str, $chk); | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 1 | 1; | |||||||||||||||||||
| 55 | __END__ | ||||||||||||||||||||