perl-unicode

"Undocumented feature" of Encode::{en,de}code()

2004-12-16 07:30:08
Hello,

What's the point of lines 151 and 167 in Encode.pm?  Respectively:

    # sub encode
    $_[1] = $string if $check;

    # sub decode
    $_[1] = $octets if $check;

I really can't see a point in overwriting the input value...  Why only
"if $check"?  An example of evilness:

  $ perl -MEncode -wle '$x=\"abc"; decode("us-ascii",$$x,1)'
  Modification of a read-only value attempted at 
/usr/lib/perl5/5.8.6/athlon-pld-linux-thread-multi/Encode.pm line 167.

Besides, the value is empty:

  $ perl -MEncode -we '$x="abc"; decode("us-ascii",$x, 1); print $x' | wc
        0       0       0

-- 
Radosław Zieliński <radek(_at_)karnet(_dot_)pl>
[ GPG key: http://radek.karnet.pl/ ]

Attachment: pgpxr9R3oPIq1.pgp
Description: PGP signature

<Prev in Thread] Current Thread [Next in Thread>