perl-unicode

Encode module question

2009-09-02 13:55:47
Dear all,

I have to decode a log file which is written in UTF-16LE on a windows platform.

When using PerlIO together with little endian "UTF-16LE" encoding it works fine:

open(FILE, "<:encoding(utf-16le)", $file)

while(<FILE>) {
  print "Decoded Line: $_";
}

But when I try to use the Encode::decode() function without PerlIO I have to 
switch the encoding to big endian UTF-16BE to get correct results:

open(FILE, $file);
my $obj=find_encoding("UTF-16BE");

while(my $line=<FILE>) {
   $line = $obj->decode($line);
   print "Decoded line: $line";
 }

This is although the $line variable seems to hold the byte characters still in 
"little endian" order.

Do you have an idea why I have to use the "wrong" big endian encoding when 
using the decode() function?

Thanks in advance for your help!

Best regards

Jens Kammler

System management / NMI-DD
---------------------------------------------------------
arvato systems GmbH
An der Autobahn 18
33311 Gütersloh
jens(_dot_)kammler(_at_)bertelsmann(_dot_)de<BLOCKED::mailto:ulrich(_dot_)niggemeier(_at_)bertelsmann(_dot_)de>

http://www.arvato-systems.de<BLOCKED::http://www.arvato-systems.de/>
Geschäftsführung: Dr. Michael Pesch
Amtsgericht Gütersloh - HRB 3981

<Prev in Thread] Current Thread [Next in Thread>
  • Encode module question, Jens.Kammler <=