#!/usr/bin/perl # require './jcode.pl'; if($#ARGV>=0) { close(STDIN); if(!open(STDIN,"$ARGV[0]")) { print STDERR "cannot open $ARGV[0]\n"; exit(1); } } if($#ARGV>=1) { close(STDOUT); if(!open(STDOUT,"> $ARGV[1]")) { print STDERR "cannot open $ARGV[1]\n"; exit(1); } } while() { s/MS-Gothic/GothicBBB-Medium-EUC-H/g; s/MS-Mincho/Ryumin-Light-EUC-H/g; if(/(\()(.*)(\)\sTx)/) { print STDERR $`,$1,$2,$3,$'; $prev=$`.$1; $next=$3.$'; $_=$2; s/\\(\d+)\\(\d+)/conv($1,$2)/ge; print STDERR $prev,$_,$next; print STDOUT $prev,$_,$next; } else { print STDOUT $_; } } sub conv{ ($c1,$c2)=@_; $c1=oct($c1); $c2=oct($c2); # print STDERR $c1," ",$c2,"\n"; $c1 -= 0x40 if $c1 >= 0xe0; $c2-- if $c2>=0x80; $j1 = ($c1-0x81)*2+($c2>=0x9e ? 1:0)+0x21; $j2=($c2>=0x9e?$c2-0x9e : $c2-0x40)+0x21; # print STDERR $j1," ",$j2,"\n"; sprintf "\\%03o\\%03o",$j1+0x80,$j2+0x80; }