Encode::decode() clears scalar being decoded?

Discussion in 'Perl Misc' started by Robert Urban, Apr 23, 2009.

  1. Robert Urban

    Robert Urban Guest

    if I run the following script:

    -snip-
    #!/usr/bin/perl

    use Encode qw/decode/;

    my $string = "B\303\266rsen Feiertag";
    print "string=[$string]\n";

    my $tmp = decode('utf8', $string, 1);
    print "string=[$string], tmp=[$tmp]\n";
    -snip-

    I get the following output:

    -snip-
    string=[Börsen Feiertag]
    string=[], tmp=[B?sen Feiertag]
    -snip-


    What happened to $string? There is no mention of side-effects in the Encode
    manpage... This only happens when CHECK is set to 1.

    cheers,

    Rob Urban
     
    Robert Urban, Apr 23, 2009
    #1
    1. Advertising

  2. Robert Urban

    Ben Bullock Guest

    On Thu, 23 Apr 2009 02:05:14 +0200, Robert Urban wrote:

    > if I run the following script:
    >
    > -snip-
    > #!/usr/bin/perl
    >
    > use Encode qw/decode/;
    >
    > my $string = "B\303\266rsen Feiertag";
    > print "string=[$string]\n";
    >
    > my $tmp = decode('utf8', $string, 1);
    > print "string=[$string], tmp=[$tmp]\n";
    > -snip-
    >
    > I get the following output:
    >
    > -snip-
    > string=[Börsen Feiertag]
    > string=[], tmp=[B?sen Feiertag]
    > -snip-


    I get the same result.

    I think it's a bug in Encode.
     
    Ben Bullock, Apr 23, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MNQ
    Replies:
    2
    Views:
    664
    Eyck Jentzsch
    May 18, 2004
  2. Harald Kirsch
    Replies:
    2
    Views:
    2,144
    Harald Kirsch
    Aug 28, 2003
  3. Clint Olsen
    Replies:
    6
    Views:
    362
    Jeff 'japhy' Pinyan
    Nov 13, 2003
  4. Mark

    Replace scalar in another scalar

    Mark, Jan 27, 2005, in forum: Perl Misc
    Replies:
    4
    Views:
    165
    Arndt Jonasson
    Jan 27, 2005
  5. Robert Urban

    Encode::decode() clears scalar being decoded?

    Robert Urban, Apr 23, 2009, in forum: Perl Misc
    Replies:
    10
    Views:
    173
Loading...

Share This Page