in reply to "use encoding" behaviour change under Perl 5.10?
In one respect, it may be that 5.10's behavior is "consistent" in a way that 5.8's behavior is not:
In 5.10, those two commands both produce "b=fffd". But knowing that probably doesn't help either (sorry).# in perl 5.8.8: perl -Mencoding=utf8 -e '$a="\x51";$b="\xE1"; printf( "a=%x b=%x\n",or +d($a),ord($b))' a=51 b=fffd perl -Mencoding=utf8 -e '$a=chr(hex("51"));$b=chr(hex("E1")); printf( +"a=%x b=%x\n",ord($a),ord($b))' a=51 b=e1
While it's probably true that maintaining your own local version of CGI::Util will be "easier", it might still make sense to consider whether there's a better way to handle this issue:
I cannot easily remove the 'use encoding "utf8"' from my script as the pragma does "some magic" that prevents encoding-related disasters (double-encoded strings) further down the road.
Figuring what that "magic" is and where it applies in your code, and then looking for better ways to achieve the same result, might be better in the long run. In particular, since "use encoding" is not scoped, replacing that solution with some other (scoped and/or focused) approach for your encoding-related disasters would seem prudent and worthwhile.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: "use encoding" behaviour change under Perl 5.10?
by gnosek (Sexton) on Mar 21, 2009 at 17:54 UTC | |
by jdd (Acolyte) on Mar 21, 2009 at 19:32 UTC |