Fandom

Scratchpad

Pastebin/User:Ans/ps char2uni.pl

< Pastebin

219,502pages on
this wiki
Add New Page
Discuss this page0 Share
A sample perl script used to convert postscript char code to unicode. The postscript file is generated by pdftops tool bundled with xpdf.
#!/usr/bin/env perl -n
 
BEGIN {
   %map = (
      "/F9_0" => [ split"",
         q[ หน้า ๑เล่ม๒๗ตอที่กรชิจุบษ๔ค๕๓ใพะปภไธยั์ศฎแผดญขงูํืวถฐส้๙๘็ซึ้.].
         q[ณ๐,ฝ่ฏ()ฤัฉฟๆฆ-๖ี็ืฮ/ฯิ์ฑฒ๋""ฬ๊                                 ].
         q[                                             -                  ].
         q[                                                                ]
      ],
      "/F11_0" => [ split"",
         q[  ,CeluarMobiTphn)E-BsPd""(O!RmgNtASDIGLUWKH-.ycFkfw&           ].
         q[ ABCDEFGHI KLMNOP RSTU W         abcdefghi klmnop rstu w y      ].
         q[                                             -                  ].
         q[                                                                ]
      ],
      "/F13_0" => [ split"",
         q[ (อม.๓๐) คําพิกษดีหยเลขท่๑๔/๒๕แงระว่,   ()  , ./                ].
         q[                                                                ].
         q[                                                                ].
         q[                                                                ]
      ],
      "/F15_0" => [ split"",
         q[  วันที่๒๖กุมภาพธ์.ศ๕๓อยรสูงดผ้ตํจโษิณชถล่หคญ๑แ๔บ๗ะเ๘ป๙ซฟิ๐ไ็ึฎ้].
         q[()ืฒขใ็                                                         ].
         q[                                                                ].
         q[                                                                ]
      ],
      "/F18_0" => [ split"",
         q[                                                                ].
         q[                                                                ].
         q[                                                                ].
         q[                                                                ]
      ],
   );
   $map = [];
   $Td = undef;
}
if (/ Tf$/) { s/ .*//s; $map = $map{$_}; next; }
if (/ Tj$/) {
   /\(/g or next;
   for (;/\G((\r)|([^\\\(\)])|\\(([0-7]{1,3})|([btnfr])|[\r\n]|([^0-7])))/g;) {
      #print$&;
      my $c;
      defined$2 and $c=ord"\n";
      defined$3 and $c=ord$3;
      defined$5 and $c=oct$5;
      defined$6 and $c=ord eval qq("$&");
      defined$7 and $c=ord$7;
      my $c2 = $map->[$c];
      if (defined $c2) { print $c2; } else { print chr$c; }
   }
   next;
}
if (/ Td$/) {
   chomp; s/\s+Td//; s/.*\s//; print "\n" if (!defined$Td || $Td!=$_); $Td=$_;
   next;
}
/ Tm$/ and $Td=undef;

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random wikia