WX2UTF.pm 854 Bytes
Newer Older
priyank's avatar
priyank committed
1 2 3 4 5
package ILMT::PAN::HIN::WX2UTF;
#use strict;
#use warnings;
use Dir::Self;
use Data::Dumper;
priyank's avatar
priyank committed
6 7 8 9 10
use IPC::Run qw(run);
use List::UtilsBy qw(max_by);
use File::Temp qw/ tempfile /;
use File::Slurp qw( slurp );
my $cwd = __DIR__;
priyank's avatar
priyank committed
11 12 13

sub process {
    my %args = @_;
priyank's avatar
priyank committed
14 15 16 17 18
    utf8::encode($args{data});
    my ($fh, $filename) = tempfile("conv111XXXX", DIR => "/tmp", SUFFIX => ".tmp");
    #binmode($fh, ":utf8");
    print $fh $args{data};
    close($fh);
priyank's avatar
priyank committed
19

priyank's avatar
priyank committed
20 21 22
    my ($fh3, $filename3) = tempfile("convout1111XXXX", DIR => "/tmp", SUFFIX => ".tmp");
    #binmode($fh3, ":utf8");
    close($fh3);
priyank's avatar
priyank committed
23

priyank's avatar
priyank committed
24 25
    my $wxtoutf1;
    run ["perl", "$cwd/WX2UTF/convertor-indic-1.4.7/convertor_indic.pl", "-f", "ssf", "-l", "pan", "-s", "wx", "-t", "utf", "-i", $filename], ">", $filename3;
priyank's avatar
priyank committed
26

priyank's avatar
priyank committed
27 28 29 30
    my $result = slurp("$filename3");
    utf8::decode($result);
    return $result;
};
priyank's avatar
priyank committed
31 32 33 34



1;