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

[perl #119027] utf8::decode and undef value

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
July 26, 2013 07:56
Subject:
[perl #119027] utf8::decode and undef value
Message ID:
rt-3.6.HEAD-2552-1374825382-915.119027-15-0@perl.org
On Thu Jul 25 23:01:31 2013, lav@yar.ru wrote:
> utf8::decode replaces undef with an empty string. This code snippet
> illustrates the problem.
> 
> use utf8;
> my $value=undef;
> utf8::decode($value);
> print defined($value)?"ERROR":"OK","\n";
> 
> perl-5.14.4 did not have this bug.

This was an intentional change, necessary to fix a bug (#91850). 
Objects with string overloading were not being decoded. 
utf8::decode($such_an_obj) simply did nothing.  So we had to change it
to stringify its argument first.  That had the side effect of changing
undef to "", which is actually logical, because decoding is a string
operation.  It also makes utf8::decode consistent with utf8::encode,
which has always changed undef to "", or at least as far as I can remember.

-- 

Father Chrysostomos


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

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