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

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

Thread Previous | Thread Next
Father Chrysostomos via RT
July 26, 2013 07:56
[perl #119027] utf8::decode and undef value
Message ID:
On Thu Jul 25 23:01:31 2013, 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

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About