open my $fh, "<:encoding(UTF-16)", "somefile.utf16le" or die "...: $!"; #### UTF-16:Malformed LO surrogate dbf4 at ... #### use Encode; use PerlIO::encoding; $PerlIO::encoding::fallback = Encode::FB_DEFAULT; # BTW, why is FB_DEFAULT not the default? my $malformed = "a\x00b\x00c\x00\xF4\xDBd\x00e\x00f\x00\n\x00" . "g\x00h\x00i\x00\n\x00"; # = "abcdef\nghi\n" in UTF-16LE open my $fh, "<:encoding(UTF-16LE)", \$malformed or die $!; while ( my $u = <$fh> ) { print $u; } close $fh; #### abc?ef ghi abc?ef ghi ... (repeated ad infinitum)