Bug in documentation for Encode::decode_utf8 ?

William Blunn bill+london.pm at blunn.org
Thu Sep 5 09:31:55 BST 2013

The documentation for Encode::decode_utf8 begins:

     $string = decode_utf8($octets [, CHECK]);

     Equivalent to $string = decode("utf8", $octets [, CHECK]).
So what should the following one-liner emit?

perl -E 'use charnames ":full"; use Encode; my $x = "\N{LATIN CAPITAL 
LETTER A WITH CIRCUMFLEX}\N{POUND SIGN}"; say decode_utf8($x) eq 
decode("utf8", $x) ? "Fine" : "WTF?"'

"Fine\n" ?

On my system it emits "WTF?\n".

It seems that decode_utf8(...) is a no-op if the input string has the 
UTF8 flag on, but decode("utf8", ...) will always try to decode 
regardless of the state of the UTF8 flag.

But the documentation says that they are equivalent.

So the documentation would appear to be at odds with the behaviour.



More information about the london.pm mailing list