#!/usr/bin/perl
use strict;
use warnings;

use Encode;
binmode(STDOUT, ":utf8");

while (defined (my $l = <>)) {
  eval { print decode("utf-8", $l, Encode::FB_CROAK); };
  next unless ($@);
  
   eval { print decode("windows-1255", $l, Encode::FB_CROAK); };

   if ($@) {
     print STDERR "Failed to decode line $.: $l\n";
     print $l;
   }
}
