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

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

Thread Next
From:
Tatsuhiko Miyagawa
Date:
May 15, 2010 06:16
Subject:
[perl #75106] binmode $fh, ":raw" doesn't undo :utf8 on win32
Message ID:
rt-3.6.HEAD-4976-1273881304-1703.75106-75-0@perl.org
# New Ticket Created by  "Tatsuhiko Miyagawa" 
# Please include the string:  [perl #75106]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=75106 >


The following test fails on win32 systems on perl 5.8.9, 5.10.1 and
5.12.0, whereas it passes fine on other systems like Linux or Mac OS
X. It looks like binmode $t, ":raw" doesn't have any effect of taking
away ":utf8". Per my discussion with jdb at #p5p, i'm filing a bug
report.

This is affecting the critical path in CGI::Emulate::PSGI where faking
a mock STDOUT handle and pass it to the existing CGI code, and then
undoing ":utf8" flag from the handle if set.

#!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);

seek $t, 0, SEEK_SET;
binmode $t, ":raw";

my $s = <$t>;
is length $s, 3;
ok !utf8::is_utf8($s);

done_testing;



---
Flags:
    category=
    severity=
---
Site configuration information for perl 5.12.0:

Configured by miyagawa at Tue Apr 13 06:26:56 CEST 2010.

Summary of my perl5 (revision 5 version 12 subversion 0) configuration:

  Platform:
    osname=darwin, osvers=10.3.0, archname=darwin-2level
    uname='darwin macbook-miyagawa.local 10.3.0 darwin kernel version
10.3.0: fri feb 26 11:58:09 pst 2010; root:xnu-1504.3.12~1release_i386
i386 '
    config_args='-de -Dprefix=/Users/miyagawa/perl5/perlbrew/perls/perl-5.12.0'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp
-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include
-I/opt/local/include',
    optimize='-O3',
    cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN
-no-cpp-precomp -fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -I/opt/local/include'
    ccversion='', gccversion='4.2.1 (Apple Inc. build 5646) (dot 1)',
gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags ='
-fstack-protector -L/usr/local/lib -L/opt/local/lib'
    libpth=/usr/local/lib /opt/local/lib /usr/lib
    libs=-ldbm -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup
-L/usr/local/lib -L/opt/local/lib -fstack-protector'

Locally applied patches:


---
@INC for perl 5.12.0:
    /Users/miyagawa/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/darwin-2level
    /Users/miyagawa/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0
    /Users/miyagawa/perl5/perlbrew/perls/perl-5.12.0/lib/5.12.0/darwin-2level
    /Users/miyagawa/perl5/perlbrew/perls/perl-5.12.0/lib/5.12.0
    .

---
Environment for perl 5.12.0:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/miyagawa
    LANG=ja_JP.UTF-8
    LANGUAGE (unset)
    LC_MESSAGES=C
    LC_TIME=C
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/Users/miyagawa/.gem/ruby/1.8/bin:/Users/miyagawa/perl5/perlbrew/bin:/Users/miyagawa/perl5/perlbrew/perls/current/bin:/Users/miyagawa/local/bin:/Users/miyagawa/bin:/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/local/bin:/usr/bin:/usr/local/ssl/bin:/usr/local/samba/bin:/usr/local/java/bin:/var/qmail/bin:/usr/local/pgsql/bin:/usr/local/mysql/bin:/usr/local/apache/bin:/usr/local/squid/bin:/usr/local/git/bin:/opt/local/bin:/opt/local/sbin
    PERL_AUTOINSTALL_PREFER_CPAN=1
    PERL_BADLANG=0
    SHELL=/bin/tcsh


-- 
Tatsuhiko Miyagawa


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