develooper Front page | perl.perl5.porters | Postings from December 2012

[perl #41368] DATA filehandle out by 1 on UTF16 source

Thread Next
From:
bulk88 via RT
Date:
December 26, 2012 21:48
Subject:
[perl #41368] DATA filehandle out by 1 on UTF16 source
Message ID:
rt-3.6.HEAD-17500-1356558521-1416.41368-15-0@perl.org
On Mon Jan 29 04:07:18 2007, adavies@ptc.com wrote:
> This is a bug report for perl from adavies@ADAVIES13D.ptcnet.ptc.com,
>    generated with the help of perlbug 1.35 running under perl v5.9.4.
>    -----------------------------------------------------------------
>    [Please enter your report here]
> 
> 
> If the the DATA filehandle is
>    read from a UTF16LE
> encoded source file (on Windows at least), it
>    appears
> the initial offset is out by 1. That is it can be fixed
>    by doing a C< seek DATA, 1, 1 >.
> 

Running (my line numbers are different than the quote below)
______________________________________________________________


# Create a UTF16LE encoded test file:
my $test_file = "DATA_test.tmp";
#END { unlink $test_file };
open FOUT, ">:raw:perlio:encoding(utf16le)", $test_file or die;

print FOUT <<'EOT';
binmode DATA, ':encoding(utf16le)';
if (0) { # XXX this is needed
seek DATA, 1, 1;
}
while(<DATA>) {
print " # $_";
}
__DATA__
1
2
3
EOT

print "START\n";
system "perl $test_file";
print "\nEND\n"; 
__________________________________________________________________

on win32 Perl 5.10

__________________________________________________________________
C:\Documents and Settings\Owner\Desktop>perl 41368.pl
START
UTF-16LE:Partial character at DATA_test.tmp line 5.
UTF-16LE:Partial character at DATA_test.tmp line 5.
Wide character in print at DATA_test.tmp line 6, <DATA> line 1.
UTF-16LE:Partial character at DATA_test.tmp line 6, <DATA> line 1.
 # ㄀਀㈀਀㌀਀
END

C:\Documents and Settings\Owner\Desktop>
__________________________________________________________________

on win32 Perl 5.12
__________________________________________________________________
C:\Documents and Settings\Owner\Desktop>perl 41368.pl
START

END

C:\Documents and Settings\Owner\Desktop>
___________________________________________________________________
on win32 Perl 5.17.6
___________________________________________________________________
C:\p517\perl\win32>perl "C:\Documents and Settings\Owner\Desktop\41368.pl"
START

END

C:\p517\perl\win32>
___________________________________________________________________

I suggest for someone who knows more about
perlio/layers/encoding/unicode to comment in this ticket on whether
there was a bug in the past in this ticket, and is there still a bug in
blead in the present or not.

-- 
bulk88 ~ bulk88 at hotmail.com

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=41368

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About