perl-unicode

Re: pack('C'...) sets UTF8 flag

2005-07-08 05:12:20
On 2005-07-07 06:27:04 PM Rafael Garcia-Suarez wrote:

This is fixed in the development branch of perl (5.9.x).
Something probably goes wrong with the localisation of UTF-8 magic.
The next 5.8.x release may have this bug fixed.

OK,  I've crafted the following module that seems to work as a patch. If 
anyone sees any problems with this please let me know!

package FixPack;
use strict;

use Encode qw(_utf8_off);

BEGIN {
*CORE::GLOBAL::pack = sub {
        my $pattern = shift;
        my $res = CORE::pack ($pattern, @_);
        _utf8_off($res) if $pattern =~ /^C/;
        $res;
        };
}
1;

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