develooper Front page | perl.perl5.porters | Postings from June 2008

Re: Perl 5.8 and perl 5.10 differences on UTF/Pack things

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
June 18, 2008 08:07
Subject:
Re: Perl 5.8 and perl 5.10 differences on UTF/Pack things
Message ID:
20080618150706.GK99534@plum.flirble.org
On Wed, Jun 18, 2008 at 03:49:27PM +0100, Alberto Simes wrote:

> By the way,
> 
>    open IDX, ">:utf8", "..."
> 
>         if (utf8::is_utf8($chave))
>           print IDX pack('a*x',$chave);
>         }
> 
> 
> does what is expected in perl 5.10 (we get the string back in UTF8)
> 
> Under perl 5.8 we are getting it double-encoded utf8.
> 
> For now, to get a portable approach, we are using:
> 
>    open IDX, ">:raw", "..."
>    { use bytes;
>                print IDX pack('a*x',$chave);
>    }
> 
> 
> Is there a cleaner way?

Avoid using 'a' in pack?
(given that you need to to work on both, and pack was fixed for 5.10)

Nicholas Clark

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About