On Thu, 10 Nov 2005 05:33:28 -0800 (PST), rajarshi das <[EMAIL PROTECTED]> wrote
> Hi,
> The following worked in perl-5.005_03 on ebcdic.
>
> $value = "http%3A%2F%2Fw3.pok.ibm.com%2Fpokcomm%2Fthanks.html";
> $value =~ s/%([a-fA-F0-9]{2})/pack('E',chr(hex($1)))/ge;
> print "value : $value\n";
>
> $value is set to "http://w3.pok.ibm.com/pokcomm/thanks.html"
Your code does not work with perl-5.005_03 available from CPAN.
As far as I know, type 'E' for pack has not been implemented yet.
cf. http://public.activestate.com/gsar/APC/perl-5.005xx/pp.c
This pp.c (perl-5.005_04+) has same pp_pack code
as that in perl-5.005_03.
I guess this pack('E') is something like an unofficially extended feature
for a perl distribution for ebcdic.
> However, the pack('E,<>) above is not supported on perl-5.8.7 on ebcdic.
> A few qns here :
> 1) Is there some utility in perl-5.8.7 that can replace pack('E',<>) in the
> above regular expression ?
method 1)
$value =~ s/%([a-fA-F0-9]{2})/chr(utf8::unicode_to_native(hex($1)))/ge;
Note. utf8::unicode_to_native and utf8::native_to_unicode
are not documented.
method 2)
$value =~ s/%([a-fA-F0-9]{2})/pack('U', hex($1))/ge;
Note. The "UTF8 flag" of $value will be turned on.
> 2) Is it allowed to add a case 'E' in the pp_pack.c code in perl-5.8.7 to do
> this ?
parhaps it will not be allowed.
Regards,
SADAHIRO Tomoyuki