| 1 | #!./perl | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # $Id: piconv,v 2.8 2016/08/04 03:15:58 dankogai Exp $ | ||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | BEGIN { pop @INC if $INC[-1] eq '.' } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use 5.8.0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Encode ; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Encode::Alias; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | my %Scheme = map {$_ => 1} qw(from_to decode_encode perlio); | |||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | my $name = basename($0); | |||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use Getopt::Long qw(:config no_ignore_case); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | my %Opt; | |||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | help() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | unless | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | GetOptions(\%Opt, | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 'from|f=s', | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 'to|t=s', | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 'list|l', | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 'string|s=s', | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 'check|C=i', | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 'c', | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 'perlqq|p', | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 'htmlcref', | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 'xmlcref', | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 'debug|D', | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 'scheme|S=s', | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 'resolve|r=s', | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 'help', | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 3 | ▶ | $Opt{help} and help(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 3 | ▶ | $Opt{list} and list_encodings(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 3 | ▶ | my $locale = $ENV{LC_CTYPE} || $ENV{LC_ALL} || $ENV{LANG}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$ENV{'LC_CTYPE'} || $ENV{'LC_ALL'} || $ENV{'LANG'}
$ENV{"LC_CTYPE"} or $ENV{"LC_ALL"}
MC/DC0%0/3
$ENV{'LC_CTYPE'} || $ENV{'LC_ALL'} || $ENV{'LANG'}
$ENV{"LC_CTYPE"}
$ENV{"LC_ALL"}
$ENV{'LANG'}
Truth table25%1/4
A or B || C
A= $ENV{"LC_CTYPE"}B= $ENV{"LC_ALL"}C= $ENV{'LANG'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 3 | ▶ | defined $Opt{resolve} and resolve_encoding($Opt{resolve}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 3 | ▶ | $Opt{from} || $Opt{to} || help(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$Opt{"from"} or $Opt{"to"}
MC/DC50%1/2
$Opt{"from"} or $Opt{"to"}
$Opt{"from"}
$Opt{"to"}
Truth table66%2/3
A or B
A= $Opt{"from"}B= $Opt{"to"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | ▶ | my $from = $Opt{from} || $locale or help("from_encoding unspecified"); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Opt{'from'} || $locale
MC/DC0%0/2
$Opt{'from'} || $locale
$Opt{'from'}
$locale
Truth table33%1/3
A || B
A= $Opt{'from'}B= $locale
| |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | my $to = $Opt{to} || $locale or help("to_encoding unspecified"); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Opt{'to'} || $locale
MC/DC0%0/2
$Opt{'to'} || $locale
$Opt{'to'}
$locale
Truth table33%1/3
A || B
A= $Opt{'to'}B= $locale
| |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | ▶ | $Opt{string} and Encode::from_to($Opt{string}, $from, $to) and print $Opt{string} and exit; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$Opt{"string"} and &Encode::from_to($Opt{"string"}, $from, $to) and print $Opt{"string"}
$Opt{"string"} and &Encode::from_to($Opt{"string"}, $from, $to)
MC/DC0%0/3
$Opt{"string"} and &Encode::from_to($Opt{"string"}, $from, $to) and print $Opt{"string"}
$Opt{"string"}
&Encode::from_to($Opt{"string"}, $from, $to)
print $Opt{"string"}
Truth table25%1/4
A and B and C
A= $Opt{"string"}B= &Encode::from_to($Opt{"string"}, $from, $to)C= print $Opt{"string"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 2 | my $scheme = do { | |||||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | ▶ | if (defined $Opt{scheme}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | ▶ | if (!exists $Scheme{$Opt{scheme}}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | warn "Unknown scheme '$Opt{scheme}', fallback to 'from_to'.\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | 'from_to'; | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $Opt{scheme}; | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | 'from_to'; | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 2 | ▶ | $Opt{check} ||= $Opt{c}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$Opt{"check"} ||= $Opt{"c"}
MC/DC0%0/2
$Opt{"check"} ||= $Opt{"c"}
$Opt{"check"}
$Opt{"c"}
Truth table33%1/3
A ||= B
A= $Opt{"check"}B= $Opt{"c"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | ▶ | $Opt{perlqq} and $Opt{check} = Encode::PERLQQ; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | ▶ | $Opt{htmlcref} and $Opt{check} = Encode::HTMLCREF; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | ▶ | $Opt{xmlcref} and $Opt{check} = Encode::XMLCREF; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | ▶ | my $efrom = Encode->getEncoding($from) || die "Unknown encoding '$from'"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
'Encode'->getEncoding($from) || die("Unknown encoding '${from}'")
MC/DC0%0/1
'Encode'->getEncoding($from) || die("Unknown encoding '${from}'")
'Encode'->getEncoding($from)
Truth table50%1/2
A
A= 'Encode'->getEncoding($from)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | ▶ | my $eto = Encode->getEncoding($to) || die "Unknown encoding '$to'"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
'Encode'->getEncoding($to) || die("Unknown encoding '${to}'")
MC/DC0%0/1
'Encode'->getEncoding($to) || die("Unknown encoding '${to}'")
'Encode'->getEncoding($to)
Truth table50%1/2
A
A= 'Encode'->getEncoding($to)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | my $cfrom = $efrom->name; | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | my $cto = $eto->name; | |||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | ▶ | if ($Opt{debug}){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | print <<"EOT"; | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | Scheme: $scheme | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | From: $from => $cfrom | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | To: $to => $cto | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | EOT | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | my %use_bom = | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | map { $_ => 1 } qw/UTF-16 UTF-16BE UTF-16LE UTF-32 UTF-32BE UTF-32LE/; | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # we do not use <> (or ARGV) for the sake of binmode() | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | ▶ | @ARGV or push @ARGV, \*STDIN; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2 | ▶ | unless ( $scheme eq 'perlio' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | binmode STDOUT; | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | ▶ | my $need2slurp = $use_bom{ $eto } || $use_bom{ $efrom }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$use_bom{$eto} || $use_bom{$efrom}
MC/DC0%0/2
$use_bom{$eto} || $use_bom{$efrom}
$use_bom{$eto}
$use_bom{$efrom}
Truth table33%1/3
A || B
A= $use_bom{$eto}B= $use_bom{$efrom}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 2 | for my $argv (@ARGV) { | |||||||||||||||||||||||||||||||||||||||||||||
| 86 | 2 | ▶ | my $ifh = ref $argv ? $argv : undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | ▶ | $ifh or open $ifh, "<", $argv or warn "Can't open $argv: $!" and next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition62%5/8
$ifh || open($ifh, '<', $argv) || warn("Can't open ${argv}: $!") && (next)
$ifh or open $ifh, "<", $argv
warn "Can't open ${argv}: $!" and next
MC/DC0%0/3
$ifh || open($ifh, '<', $argv) || warn("Can't open ${argv}: $!") && (next)
$ifh
open $ifh, "<", $argv
warn "Can't open ${argv}: $!"
Truth table25%1/4
A or B || C
A= $ifhB= open $ifh, "<", $argvC= warn "Can't open ${argv}: $!"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 1 | ▶ | $ifh or open $ifh, "<", $argv or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ifh or open $ifh, "<", $argv
MC/DC0%0/2
$ifh or open $ifh, "<", $argv
$ifh
open $ifh, "<", $argv
Truth table33%1/3
A or B
A= $ifhB= open $ifh, "<", $argv
| |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | binmode $ifh; | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | ▶ | if ( $scheme eq 'from_to' ) { # default | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | ▶ | if ($need2slurp){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | local $/; | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $_ = <$ifh>; | |||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | Encode::from_to( $_, $from, $to, $Opt{check} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | print; | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | ▶ | while (<$ifh>) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 319 | Encode::from_to( $_, $from, $to, $Opt{check} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | 319 | print; | |||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | elsif ( $scheme eq 'decode_encode' ) { # step-by-step | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if ($need2slurp){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | local $/; | |||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $_ = <$ifh>; | |||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my $decoded = decode( $from, $_, $Opt{check} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my $encoded = encode( $to, $decoded ); | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | print $encoded; | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | while (<$ifh>) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my $decoded = decode( $from, $_, $Opt{check} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $encoded = encode( $to, $decoded ); | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | print $encoded; | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | else { # won't reach | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | die "$name: unknown scheme: $scheme"; | |||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # NI-S favorite | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | binmode STDOUT => "raw:encoding($to)"; | |||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | for my $argv (@ARGV) { | |||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | my $ifh = ref $argv ? $argv : undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | $ifh or open $ifh, "<", $argv or warn "Can't open $argv: $!" and next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/8
$ifh || open($ifh, '<', $argv) || warn("Can't open ${argv}: $!") && (next)
$ifh or open $ifh, "<", $argv
warn "Can't open ${argv}: $!" and next
MC/DC0%0/3
$ifh || open($ifh, '<', $argv) || warn("Can't open ${argv}: $!") && (next)
$ifh
open $ifh, "<", $argv
warn "Can't open ${argv}: $!"
Truth table0%0/4
A or B || C
A= $ifhB= open $ifh, "<", $argvC= warn "Can't open ${argv}: $!"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | $ifh or open $ifh, "<", $argv or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ifh or open $ifh, "<", $argv
MC/DC0%0/2
$ifh or open $ifh, "<", $argv
$ifh
open $ifh, "<", $argv
Truth table0%0/3
A or B
A= $ifhB= open $ifh, "<", $argv
| |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | binmode $ifh => "raw:encoding($from)"; | |||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | print while (<$ifh>); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | sub list_encodings { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_encodings: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | print join( "\n", Encode->encodings(":all") ), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | exit 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | sub resolve_encoding { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve_encoding: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if ( my $alias = Encode::resolve_alias( $_[0] ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | print $alias, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | exit 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | warn "$name: $_[0] is not known to Encode\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | ▶ | sub help { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
help: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | my $message = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | ▶ | $message and print STDERR "$name error: $message\n"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | print STDERR <<"EOT"; | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | $name [-f from_encoding] [-t to_encoding] | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | [-p|--perlqq|--htmlcref|--xmlcref] [-C N|-c] [-D] [-S scheme] | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | [-s string|file...] | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | $name -l | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | $name -r encoding_alias | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | $name -h | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | Common options: | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | -l,--list | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | lists all available encodings | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | -r,--resolve encoding_alias | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | resolve encoding to its (Encode) canonical name | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | -f,--from from_encoding | ||||||||||||||||||||||||||||||||||||||||||||||
| 168 | when omitted, the current locale will be used | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | -t,--to to_encoding | ||||||||||||||||||||||||||||||||||||||||||||||
| 170 | when omitted, the current locale will be used | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | -s,--string string | ||||||||||||||||||||||||||||||||||||||||||||||
| 172 | "string" will be the input instead of STDIN or files | ||||||||||||||||||||||||||||||||||||||||||||||
| 173 | The following are mainly of interest to Encode hackers: | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | -C N | -c check the validity of the input | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | -D,--debug show debug information | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | -S,--scheme scheme use the scheme for conversion | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | Those are handy when you can only see ASCII characters: | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | -p,--perlqq transliterate characters missing in encoding to \\x{HHHH} | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | where HHHH is the hexadecimal Unicode code point | ||||||||||||||||||||||||||||||||||||||||||||||
| 180 | --htmlcref transliterate characters missing in encoding to &#NNN; | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | where NNN is the decimal Unicode code point | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | --xmlcref transliterate characters missing in encoding to &#xHHHH; | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | where HHHH is the hexadecimal Unicode code point | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | EOT | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | exit; | |||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||
| 189 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||