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

[perl #40401] PerlIO::encoding doesn't handle fallback modes correctly?

From:
James E Keenan via RT
Date:
May 26, 2013 17:00
Subject:
[perl #40401] PerlIO::encoding doesn't handle fallback modes correctly?
Message ID:
rt-3.6.HEAD-2650-1369587596-1054.40401-15-0@perl.org
On Fri Sep 22 09:39:20 2006, shay wrote:
> This is a bug report for perl from steveh@Mugwump.uk.radan.com,
> generated with the help of perlbug 1.35 running under perl 5.9.4.
> 
> 
> -----------------------------------------------------------------
> [Please enter your report here]
> 
> I'm trying to use the FB_HTMLCREF fallback mode with PerlIO::encoding, 
> but it isn't doing what I expect.
> 
> If I set $PerlIO::encoding::fallback to Encode::FB_HTMLCREF (or, 
> equivalently, to Encode::HTMLCREF | Encode::LEAVE_SRC) and set the 
> STDOUT encoding layer to 'encoding(windows-1252)' then any output to 
> STDOUT seems to be repeated, regardless of whether the fallback 
> mechanism comes into play or not:
> 
>  >.\perl -MEncode -MPerlIO::encoding -e "$PerlIO::encoding::fallback = 
> Encode::FB_HTMLCREF; binmode STDOUT, ':encoding(windows-1252)'; print 
> qq[\x{0104}]"
> ĄĄ
>  >.\perl -MEncode -MPerlIO::encoding -e "$PerlIO::encoding::fallback = 
> Encode::HTMLCREF | Encode::LEAVE_SRC; binmode STDOUT, 
> ':encoding(windows-1252)'; print qq[\x{0104}]"
> ĄĄ
>  >.\perl -MEncode -MPerlIO::encoding -e "$PerlIO::encoding::fallback = 
> Encode::FB_HTMLCREF; binmode STDOUT, ':encoding(windows-1252)'; print 
> qq[abc]"
> abcabc
>  >.\perl -MEncode -MPerlIO::encoding -e "$PerlIO::encoding::fallback = 
> Encode::HTMLCREF | Encode::LEAVE_SRC; binmode STDOUT, 
> ':encoding(windows-1252)'; print qq[abc]"
> abcabc
> 
> Using the HTMLCREF bitmask flag without the LEAVE_SRC flag seems to fix 
> this, but unless I'm missing something the above behaviour is not correct:
> 
>  >.\perl -MEncode -MPerlIO::encoding -e "$PerlIO::encoding::fallback = 
> Encode::HTMLCREF; binmode STDOUT, ':encoding(windows-1252)'; print 
> qq[\x{0104}]"
> Ą
>  >.\perl -MEncode -MPerlIO::encoding -e "$PerlIO::encoding::fallback = 
> Encode::HTMLCREF; binmode STDOUT, ':encoding(windows-1252)'; print
qq[abc]"
> abc
> 
> Encode::encode() doesn't have this problem (and leaving out the 
> LEAVE_SRC flag in that case, of course, causes trouble if the source 
> string cannot be modified):
> 
>  >.\perl -MEncode -e "print encode('windows-1252', qq[\x{0104}], 
> Encode::FB_HTMLCREF)"
> Ą
>  >.\perl -MEncode -e "print encode('windows-1252', qq[\x{0104}], 
> Encode::HTMLCREF | Encode::LEAVE_SRC)"
> Ą
>  >.\perl -MEncode -e "print encode('windows-1252', qq[\x{0104}], 
> Encode::HTMLCREF)"
> Modification of a read-only value attempted at 
> C:/p5p/bleadperl/lib/Encode.pm line 147.
> 
> [Please do not change anything below this line]
> -----------------------------------------------------------------
> ---
> Flags:
>      category=library
>      severity=medium
> ---
> Site configuration information for perl 5.9.4:

Could someone familiar with PerlIO issues take a crack at this ticket
under Perl 5.18.0?

Thank you very much.
Jim Keenan


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



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