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

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

Thread Previous | Thread Next
Tatsuhiko Miyagawa
May 15, 2010 19:59
Re: [perl #75106] binmode $fh, ":raw" doesn't undo :utf8 on win32
Message ID:
On Sat, May 15, 2010 at 10:52 AM, Eric Brine <> wrote:

>> # New Ticket Created by  "Tatsuhiko Miyagawa"
>> # Please include the string:  [perl #75106]
>> # in the subject line of all future correspondence about this issue.
>> # <URL: >
>> 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.
> As a workaround, change
> binmode $t, ":utf8";
> to
> binmode $t, ":encoding(UTF-8)";

No, I can't.

This the core of CGI-to-PSGI automatic conversion, and my module
(CGI::Emulate::PSGI) runs *someone else's* (i.e. users of this module)
code that touches STDOUT, including the common idiom binmode STDOUT,

My code is a caller of CGI application, and what it does is to swap
STDOUT handle to the tempfile, run the existing CGI code, and then
undo/revert whatever perlio layer changes with binmode $h, ':raw';

Requiring the change for existing code is not an acceptable
workaround. (Yes, I understand that this is a rare requirement)

Tatsuhiko Miyagawa

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About