I wish I could answer your question, but all I can do is point out that comparing 5.8.8 and 5.10 in terms of their respective "encoding.pm" and "utf8.pm" files doesn't seem to help. The only real diffs (apart from changes in white-space usage) involve the POD, and those diffs don't really shed any light on this issue.

In one respect, it may be that 5.10's behavior is "consistent" in a way that 5.8's behavior is not:

# 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
In 5.10, those two commands both produce "b=fffd". But knowing that probably doesn't help either (sorry).

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.


In reply to Re: "use encoding" behaviour change under Perl 5.10? by graff
in thread "use encoding" behaviour change under Perl 5.10? by gnosek

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.