All pastes #968649 Raw Edit

Stuff

public text v1 · immutable
·published 2008-04-03 05:54 UTC
rendered paste body
#!/usr/bin/perl -w
use strict;
use utf8;
use encoding 'utf8';
use Encode;
use Encode::Detect::Detector;

open(FILE, "<$ARGV[0]");
my $file;
{
  local $/ = undef;
  $file = <FILE>;
}
close(FILE);

foreach my $line (split("\n", $file)) {
  my $charset = detect($line);
  if($charset) {
    my $data = decode($charset, $line);
    print "$data :::$charset";
  }else{
    print $line;
  }
  print "\n";
}