#!/usr/local/bin/perl # Written by Roytman Alexey # email: # 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=' '; $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 '; #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 ; } elsif (/.*m2.*/){ $from=$Tbl_MIC ; } elsif (/.*o2.*/){ $from=$Tbl_GOST_main ; } 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 ; } elsif (/.*2m.*/){ $to=$Tbl_MIC ; } elsif (/.*2o.*/){ $to=$Tbl_GOST_main ; } else { die "Invalid switch $_\n"; } last SWITCH; } elsif (($#ARGV == -1) or ($ARGV[0] =~ "(-)+h(elp)?")) # 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,m,o}\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.