develooper Front page | perl.perl5.porters | Postings from May 2010

Re: [perl #75106] binmode $fh, ":raw" doesn't undo :utf8 on win32

Thread Previous
From:
Tatsuhiko Miyagawa
Date:
May 16, 2010 00:41
Subject:
Re: [perl #75106] binmode $fh, ":raw" doesn't undo :utf8 on win32
Message ID:
AANLkTimq5mCDLBOMlkcI4fgse4JpE4u-U0jjpSAH7djf@mail.gmail.com
On Sat, May 15, 2010 at 9:29 PM, Eric Brine <ikegami@adaelis.com> wrote:
> A workaround that will work for you is to make a new handle from the fd.
> (Creating a new handle from the handle suffers from the bug too.) As a
> possible bonus, you don't affect the layers of the original handle.

Nice. I'll upload a new version of the module to see if it makes
testers happy. Thank you!

>
> #!perl
> use strict;
> use IO::File;
> use POSIX qw(SEEK_SET);
> use Test::More;
>
> my $t = IO::File->new_tmpfile;
> binmode $t, ":utf8";
> print $t chr(3434);
>
> $t->flush;
> open my $t2, '<&=:perlio:raw', fileno($t) or die $!;
> seek $t2, 0, SEEK_SET;
>
> my $s = <$t2>;
> is length $s, 3;
> ok !utf8::is_utf8($s);
>
> done_testing;
>
>



-- 
Tatsuhiko Miyagawa

Thread Previous


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