perl-unicode

:encoding() layer modifies read-only scalars

2004-10-31 16:30:04
Hi,

  Enocde 2.08, PerlIO::scalar 0.02, ActivePerl 5.8.2, 

  #!perl -w
  use strict;
  use warnings;
  use Encode;
  
  my $string = encode(UTF16 => "");
  
  for (qw/UTF-8 UTF-16LE UTF-16BE UTF-32LE UTF-32BE/)
  {
    my $backup = $string;
    open F, "<:encoding($_)", \$backup;
    my $char;
    read F, $char, 1, 0;
    close F;
  
    die unless $backup eq $string;
  }
  
Gives

  utf8 "\xFE" does not map to Unicode at ... line 13.
  utf8 "\xFF" does not map to Unicode at ... line 13.
  Unicode character 0xfffe is illegal at ... line 13.
  Died at ... line 16.

It modifies the read-only scalar. Is this a bug or did I miss some
documentation? I do not really expect read(...) to write(...) to
something that is read-only...

TIA.

<Prev in Thread] Current Thread [Next in Thread>
  • :encoding() layer modifies read-only scalars, Bjoern Hoehrmann <=