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
From:
Tatsuhiko Miyagawa
Date:
May 15, 2010 19:59
Subject:
Re: [perl #75106] binmode $fh, ":raw" doesn't undo :utf8 on win32
Message ID:
AANLkTimU88VM9oK7ikH3KumPdEKnpwp36k6utzF2xKoE@mail.gmail.com
On Sat, May 15, 2010 at 10:52 AM, Eric Brine <ikegami@adaelis.com> 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: 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.
>>
>
> 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,
':utf8';

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


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