On Sat Mar 31 08:44:43 2012, perl@renee-baecker.de wrote:
> This is a bug report for perl from perl@renee-baecker.de,
> generated with the help of perlbug 1.39 running under perl 5.15.9.
>
>
> -----------------------------------------------------------------
>
> I find the output of this program quite confusing:
>
> use v5.15;
>
> use strict;
> use warnings;
>
> say "\N{PLUS-MINUS SIGN}<>";
> say "\N{PLUS-MINUS SIGN}<>\N{PLUS MINUS SIGN}";
> say "\N{PLUS-MINUS SIGN}<>";
>
> {
> use charnames qw(:loose);
> say "\N{PLUS-MINUS SIGN}<>\N{PLUS MINUS SIGN}";
> }
>
> Output:
> reneeb@ubuntu$ perl unicode.pl
> Unknown charname 'PLUS MINUS SIGN' at unicode_bug.pl line 9.
> �<>
> Wide character in say at unicode_bug.pl line 9.
> ±<>�
> �<>
> �<>�
>
> The "PLUS-MINUS SIGN" is printed only once...
The wide character warning is there for a reason. The plus-minus sign
is a Latin-1 character, and STDOUT is byte-sized by default. Apparently
you are using a UTF-8 terminal, which is why the Latin-1 plus-minus sign
shows up as some sort of replacement character.
\N{...} returns U+FFFD for invalid character names, so the second ‘say’
is fed a string that does not fit in Latin-1. So you get a wide
character warning and utf8 output.
If you run that script with perl -CS, the output is as follows:
±<>
±<>�
±<>
±<>±
So, no, this is not a bug.
--
Father Chrysostomos
---
via perlbug: queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=112162