#! /usr/local/bin/perl # Convert from JIS X0212 character to ISO 8859 1 # target: PostScript code created by netscape HTML->PS engine. # [sample] # (before) -----------> (after) # 181.8 742.9 moveto 181.8 742.9 moveto # 10 of 10 f0 # <8f81eb> show (\251) show @search_table = split(' ', "8f81c0 8f81ee 8f81c1 8f81eb 8f81ea 8f81ec 8f81b2 8f81af 8f81e9 8f81c2 " . "8f85a0 8f859f 8f85a2 8f85a8 8f85a1 8f85a7 8f8540 8f85ac 8f85b0 8f85af " . "8f85b2 8f85b1 8f85be 8f85bd 8f85c0 8f85bf 8f85ce 8f85d0 8f85cf 8f85d2 " . "8f85d6 8f85d1 8f854b 8f85e1 8f85e0 8f85e3 8f85e2 8f85f0 8f854f 8f856d " . "8f8641 8f8640 8f8643 8f8649 8f8642 8f8648 8f8560 8f864d 8f8651 8f8650 " . "8f8653 8f8652 8f865f 8f865e 8f8661 8f8660 8f8562 8f866f 8f8671 8f8670 " . "8f8673 8f8677 8f8672 8f856b 8f8683 8f8682 8f8685 8f8684 8f8692 8f856f " . "8f8693"); @replace_table = split(' ', "241 244 246 251 252 256 257 270 272 277 " . "300 301 302 303 304 305 306 307 310 311 " . "312 313 314 315 316 317 321 322 323 324 " . "325 326 330 331 332 333 334 335 336 337 " . "340 341 342 343 344 345 346 347 350 351 " . "352 353 354 355 356 357 360 361 362 363 " . "364 365 366 370 371 372 373 374 375 376 " . "377"); while (<>) { if (/^%%Creator: Mozilla/) { # Mozilla's PostScript $mozilla = 1; $print; last; } print; # print through } if ($mozilla) { while (<>) { if (! /8f8[0-9a-f]{3}/) { print; # print through next; } $match = 0; ($code) = /^<([0-9a-f]+)> show$/o; # " show" -> "xxxx..." for ($i=0; $i<=$#search_table; $i++) { $offset = 0; while (($pos = index($code, "$search_table[$i]", $offset)) >= 0) { $position[$match++] = $pos; $type[$pos] = $i; $offset = $pos + 1; } } if ($match == 0) { # no need to process; print through print; next; } $offset = 0; foreach $elem (sort {$a <=> $b} @position) { m/([0-9a-f]+)/; $code = $1; $normal = substr($code, $offset, $elem - $offset); $offset = $elem + length($search_table[$type[$elem]]); if ($normal ne "") { print "12 of\n"; print "<$normal> show\n"; } print "12 f0\n"; print "(\\$replace_table[$type[$elem]]) show\n"; } } }