develooper Front page | perl.perl5.porters | Postings from October 2013

[perl #119499] $! returned with UTF-8 flag under UTF-8 locales only under 5.19.2+

Thread Next
From:
Father Chrysostomos via RT
Date:
October 22, 2013 20:48
Subject:
[perl #119499] $! returned with UTF-8 flag under UTF-8 locales only under 5.19.2+
Message ID:
rt-3.6.HEAD-26210-1382474887-1932.119499-15-0@perl.org
On Wed Oct 09 18:46:47 2013, public@khwilliamson.com wrote:
> Until the commit that generated this ticket, $! returned the bytes that 
> comprise the message regardless of whether the message was in UTF-8 or 
> not.  Thus it behaved as if it were in the scope of both 'use locale' 
> and 'use bytes'.  What the commit effectively did was to remove the 'use 
> bytes' behavior, causing $! to behave as any other string scalar does 
> under 'use locale'.  Many people on this list think that we should get 
> rid of 'use bytes'; that its behavior is never desired.  (I'm not one of 
> them BTW, but I think it should be used only very rarely.)  Thus, on the 
> face of it, it is suspect that $! should behave as if it is in 'use 
> bytes', and I'm having a hard time groking the argument that we should 
> revert back to that.

The problem with the bytes pragma is that two scalars may compare equal
($a eq $b) outside its scope, but be different ($a ne $b) within its
scope.  It changes the contents of scalars, but only some scalars.

$! does not do that.  In fact, it is more akin to the default input and
output streams, which do not do any automatic decoding or encoding until
one asks for it.

I don’t have enough room in my brain to fit all the issues that are
currently going on, so I can’t really comment on what makes sense under
‘use locale’.  But I would ask that you consider things at a more
practical level.

Simple programs like ack that do not take encodings into account should
work without any change.  The one-liner that I posted is still broken in
bleadperl.  Try running

LC_ALL=hu_HU.utf8 perl -e 'open "oentuheon" or die $!' 

on dromedary with and without bleadperl.  That type of code should
continue to work, regardless of what we come up with.

Maybe what you are really after is a *function* that returns a decoded $!.

-- 

Father Chrysostomos


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

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