perl-unicode

Re: UTF-16, Perl and Microsoft...

2003-04-04 19:30:04

On Thu, 3 Apr 2003 20:50:27 +0200 (CEST)
"Matthias Herlitzius" <mh(_at_)aiticon(_dot_)de> wrote:

$infile = "infile.xml";
$outfile = "outfile.xml";

open my $in,  "<:encoding(UTF-16LE)", $infile  or die;
open my $out, ">:encoding(UTF-16LE)", $outfile or die;

while (<$in>) {
      print $out $_;
}

close ($out);
close ($in);

The automatical CRLF <==> LF conversion in the text mode
should be avoided.
(remember binmode() has been and will be used for binary mode.)

:raw:encoding(UTF-16LE) instead of encoding(UTF-16LE)
may resolve this problem. (if I am not mistaken...)

open my $in,  "<:raw:encoding(UTF-16LE)", $infile  or die;
open my $out, ">:raw:encoding(UTF-16LE)", $outfile or die;

Regards,
SADAHIRO Tomoyuki

<Prev in Thread] Current Thread [Next in Thread>