Skip Menu |
 

This queue is for tickets about the Encode CPAN distribution.

Report information
The Basics
Id: 116904
Status: resolved
Priority: 0/
Queue: Encode

People
Owner: Nobody in particular
Requestors: pali [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.86
Fixed in: (no value)



Subject: Encode::encode_utf8(undef) returns "", not undef
Download (untitled) / with headers
text/plain 857b
In Encode documentation for encode_utf8 function [1] is written: $octets = encode_utf8($string); Equivalent to $octets = encode("utf8", $string). Next, in documentation for encode function [2] is writte: $octets = encode(ENCODING, STRING[, CHECK]) If the $string is undef, then undef is returned. So from documentation can be deducted that encode_utf8(undef) should return undef. But instead it returns "" (empty string): $ perl -MEncode -MData::Dumper -E 'print Dumper Encode::encode_utf8(undef);' Use of uninitialized value in subroutine entry at Encode.pm line 257. $VAR1 = ''; Just to check encode("utf8", undef) really returns undef: $ perl -MEncode -MData::Dumper -E 'print Dumper Encode::encode("utf8", undef);' $VAR1 = undef; [1] - https://metacpan.org/pod/Encode#encode_utf8 [2] - https://metacpan.org/pod/Encode#encode
Download (untitled) / with headers
text/plain 1022b
Pulled: https://github.com/dankogai/p5-encode/pull/62 Dan the Maintainer Thereof On Thu Aug 11 08:24:54 2016, PALI wrote: Show quoted text
> In Encode documentation for encode_utf8 function [1] is written: > > $octets = encode_utf8($string); > > Equivalent to $octets = encode("utf8", $string). > > Next, in documentation for encode function [2] is writte: > > $octets = encode(ENCODING, STRING[, CHECK]) > > If the $string is undef, then undef is returned. > > So from documentation can be deducted that encode_utf8(undef) should > return undef. But instead it returns "" (empty string): > > $ perl -MEncode -MData::Dumper -E 'print Dumper > Encode::encode_utf8(undef);' > Use of uninitialized value in subroutine entry at Encode.pm line 257. > $VAR1 = ''; > > Just to check encode("utf8", undef) really returns undef: > > $ perl -MEncode -MData::Dumper -E 'print Dumper Encode::encode("utf8", > undef);' > $VAR1 = undef; > > [1] - https://metacpan.org/pod/Encode#encode_utf8 > [2] - https://metacpan.org/pod/Encode#encode


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.