#!/usr/local/bin/perl # Written by Roytman Alexey # email: roytman AT cs DOT bgu DOT ac DOT il # http://www.cs.bgu.ac.il/~roytman/ $Tbl_GOST_alt= ' \377'; $Tbl_GOST_main= ' ߛ\377'; $Tbl_MIC= ' \077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077߰\377'; $Tbl_KOI8= ' \377Аѳ'; $Tbl_BESTA= ' 𐑒\377񣳙'; $Tbl_CP1251= ' \377 '; $Tbl_ISO8859_5= ' '; $Tbl_KOI7= ' abwgdevzijklmnoprstufhc\176\173\175\042yx\174\140qABWGDEVZIJKLMNOP RSTUFHC\136\133\135\137YX\134\100Q\044\043 '; $Tbl_KOI7_inv= ' ABWGDEVZIJKLMNOPRSTUFHC\136\133\135\137YX\134\100Qabwgdevzijklmnop rstufhc\176\173\175\042yx\174\140q\043\044 '; $Tbl_Macintosh= ' \377'; #print "\$0=$0 \$#ARGV=$#ARGV \@ARGV=\(@ARGV\)\n"; $from = 'nop'; $to = 'nop'; $_ = $ARGV[0]; SWITCH: { if (/-.2./) { # print "\-X2Y\n"; if (/.*a2.*/){ $from=$Tbl_GOST_alt ; } elsif (/.*k2.*/){ $from=$Tbl_KOI8 ; } elsif (/.*b2.*/){ $from=$Tbl_BESTA ; } elsif (/.*72.*/){ $from=$Tbl_KOI7 ; } elsif (/.*l2.*/){ $from=$Tbl_KOI7_inv ; } elsif (/.*w2.*/){ $from=$Tbl_CP1251 ; } elsif (/.*i2.*/){ $from=$Tbl_ISO8859_5 ; } elsif (/.*g2.*/){ $from=$Tbl_MIC ; } elsif (/.*o2.*/){ $from=$Tbl_GOST_main ; } elsif (/.*m2.*/){ $from=$Tbl_Macintosh ; } if (/.*2a.*/){ $to=$Tbl_GOST_alt ; } elsif (/.*2k.*/){ $to=$Tbl_KOI8 ; } elsif (/.*2b.*/){ $to=$Tbl_BESTA ; } elsif (/.*27.*/){ $to=$Tbl_KOI7 ; } elsif (/.*2l.*/){ $to=$Tbl_KOI7_inv ; } elsif (/.*2w.*/){ $to=$Tbl_CP1251 ; } elsif (/.*2i.*/){ $to=$Tbl_ISO8859_5 ; } elsif (/.*2g.*/){ $to=$Tbl_MIC ; } elsif (/.*2o.*/){ $to=$Tbl_GOST_main ; } elsif (/.*2m.*/){ $to=$Tbl_Macintosh ; } else { die "Invalid switch $_\n"; } last SWITCH; } elsif (($#ARGV == -1) or ($ARGV[0] =~ /^(-)(-)?h(elp)?$/i)) # Eats '-hu' as helpmode. { print "helpmode\n"; print "Usage: $0 option\n"; print " where option is of form '-X2Y'\n"; print " where 'X' and 'Y' are from the set {a,k,b,7,l,w,i,g,o,m}\n"; print " (alternative,koi8,besta,koi7,latin,winCP1251,iso,main,osnovnaja,macintosh)\n"; print "For more help refer to the original ReCoder\n"; exit; } else #filename(s) { print "filename: $ARGV[0]\n"; exit; } } #$from="abc"; #$to="ABC"; #print ".$from.\n\n"; #print ".$to.\n\n"; if ($from eq 'nop') { die "Source encoding not set.\n"; } if ($to eq 'nop') { die "Destination encoding not set.\n"; } while () { #eval "tr/$from/$to/, 1" or die $@; eval "tr/$from/$to/"; print; } #End.