in reply to Re: perl read a file on Windows is very strange
in thread perl read a file on Windows is very strange
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: perl read a file on Windows is very strange
by perlisfun (Sexton) on Nov 23, 2010 at 17:46 UTC |