Bug in documentation for Encode::decode_utf8 ?
Jason Clifford
jason at ukfsn.org
Thu Sep 5 10:08:30 BST 2013
On 2013-09-05 09:31, William Blunn wrote:
> 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.
Yes. Looking at the code decode_utf8 has "return $_ if is_utf8($_)" as
it's first line which decode does not.
decode_utf8 also lacks the a check that find_encoding('utf8') succeeded
before using it however if that causes a problem it's because there are
far bigger problems. Another difference is that decode_utf8 appends ''
if $_ is a reference while decode() appends '' without any condition.
More information about the london.pm
mailing list