| 1 | package Convert::EastAsianWidth; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use 5.008; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Exporter; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | our $VERSION = '1.02'; | |||||||||
| 8 | 1 | our @ISA = 'Exporter'; | |||||||||
| 9 | 1 | our @EXPORT = qw(to_fullwidth to_halfwidth); | |||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | sub to_fullwidth { | ||||||||
|
Subroutine
to_fullwidth: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||
| 12 | 1 | my $text; | |||||||||
| 13 | 1 | my $enc = $_[1]; | |||||||||
| 14 | |||||||||||
| 15 | 1 | ▶ | if ($enc) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 1 | require Encode; | |||||||||
| 17 | 1 | $text = Encode::decode($enc => $_[0]); | |||||||||
| 18 | } | ||||||||||
| 19 | else { | ||||||||||
| 20 | 0 | $text = $_[0]; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 1 | $text =~ tr/ -~/\x{3000}\x{FF01}-\x{FF5E}/; | |||||||||
| 24 | |||||||||||
| 25 | 1 | ▶ | return ( $enc ? Encode::encode($enc => $text) : $text ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 1 | ▶ | sub to_halfwidth { | ||||||||
|
Subroutine
to_halfwidth: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||
| 29 | 1 | my $text; | |||||||||
| 30 | 1 | my $enc = $_[1]; | |||||||||
| 31 | |||||||||||
| 32 | 1 | ▶ | if ($enc) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 1 | require Encode; | |||||||||
| 34 | 1 | $text = Encode::decode($enc => $_[0]); | |||||||||
| 35 | } | ||||||||||
| 36 | else { | ||||||||||
| 37 | 0 | $text = $_[0]; | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 1 | $text =~ tr/\x{3000}\x{FF01}-\x{FF5E}/ -~/; | |||||||||
| 41 | |||||||||||
| 42 | 1 | ▶ | return ( $enc ? Encode::encode($enc => $text) : $text ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | } | ||||||||||
| 44 | 1 | 1; | |||||||||
| 45 | |||||||||||
| 46 | __END__ | ||||||||||