Hi Autrijus,

thanks for reflecting this issue so quickly! Applying your new v0.02
to my sample code resulted in

Modification of a read-only value attempted at 
<dir_to_perls_lib>/Encode/compat/common.pm line 86.

Line 86 is the new implementation to normalize 'utf8' to 'utf-8':

     my ($from, $to) = map { s/^utf8$/utf-8/i; lc($_) } ($_[1], $_[2]);

But this fails due to the attempt to change $_[1]. I fixed this by
replacing this line by

        my ($from, $to) = @_[1, 2];
        ($from, $to) = map {
                s/^utf8$/utf-8/i;
                s/^shiftjis$/shift_jis/i;
                lc;
        } ($from, $to);

This also allows 'shiftjis' to be used instead of 'shift_jis'. Now
Encode::compat works like a charme with Perl 5.6.1, just like Encode
in 5.8! Great!

best,
rob.


--
On Tue, 24 Sep 2002, 10:47 GMT+08 (04:47 local time) Autrijus Tang
wrote:

> On Sun, Sep 22, 2002 at 10:08:15PM +0200, Robert Allerstorfer wrote:
>> unlike stated in my previous 2 postings from the previous thread, I finally
>> commented everything within
>> 
>> if ($] >= 5.007001 or $INC{'Encode.pm'}) {
>>     # nothing happens -- Encode.pm already available.
>>     $INC{'Encode.pm'} = __FILE__;
>>     require Encode::compat::common;
>>     require Encode::compat::5006001;
>> }

> Oops, that's just for debug use.  Stupid me.  0.02 released.

>> I have tested it with the following CGI code that should print the "?"
>> character UTF-8 encoded and the byte numbers that represent it (C3 and
>> A4):
>> 
>>         use Encode::compat;
>>         use Encode;
>>         my $string = "?";
>>         Encode::from_to($string, "iso-8859-1", "utf8");

> Forgot to normalize 'utf8' to 'utf-8'.

> Please grab the new tarball here:
>     http://www.autrijus.org/Encode-compat-0.02.tar.gz

> /Autrijus/

Reply via email to