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

[perl #128096] use open doesn't affect magic diamond operator

From:
Tony Cook via RT
Date:
May 17, 2016 05:16
Subject:
[perl #128096] use open doesn't affect magic diamond operator
Message ID:
rt-4.0.18-16019-1463462210-740.128096-15-0@perl.org
On Sat May 07 13:14:28 2016, ambs wrote:
> Sorry, probably I pushed the trigger too fast, but:
> 
> while (<>) { say }   # seems to print everything good (byte wise).
> 
> ///
> 
> use open ":encoding(utf-8)";
> while (<>) { say }   # prints something strange
>                      # file -i says
>                      # text/plain; charset=unknown-8bit
> 
> ///
> 
> binmode STDOUT, ":encoding(utf-8)";
> while (<>) { say }   # double encoding
> 
> So, I would say there *is* some bug...

Am I right in assuming you're only talking about when <> falls back to STDIN.

It seems to work ok when filename are supplied:

$ ./perl -Ilib -le 'use open ":encoding(UTF-8)"; while (<>) { print ord }' foo
257

(foo contains a single "\x{101}")

Tony

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



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