That will fail to convert CR LF to LF even though :crlf is used, and it will corrupt a number of character combinations. (Specifically, the character U+0A0D and pairs of the form U+0Dxx U+xx0A.)
Fix if you want CR LF ⇒ LF conversion:
open my $fh, '<:raw:perlio:encoding(UTF-16LE):crlf', $filename or die "Couldn't read '$filename': $! / $^E";
Fix if you want to leave CR LF intact:
open my $fh, '<:raw:perlio:encoding(UTF-16LE)', $filename or die "Couldn't read '$filename': $! / $^E";
(Mind you, corruption is very unlikely to occur since you'd have to be dealing with Malayalam characters. The non-functioning :crlf layer a more likely problem.)
It's unfortunate that one has to go through these shenanigans when dealing with non-ASCII encodings.
In reply to Re^2: perl read a file on Windows is very strange
by ikegami
in thread perl read a file on Windows is very strange
by perlisfun
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |