You said: "On the new server, it is printed as one byte: E9."

If that is really true (a perl string value representing e-acute, when printed, really is just one byte), I would expect that there is something else on the new server (not directly involved with DBI or DBD, and maybe only tangentially related to Perl) that is converting data from utf8 to some non-Unicode encoding (typically cp1252 or iso-8859-1) - I don't know what it could be (maybe a locale setting or other detail affecting your shell environment?), but some other tests of unicode/utf8-related actions on old vs. new systems (assuming the old system is still accessible/usable) could help diagnose where the difference(s) may be.

As for "combing a multitude of code" to handle the encoding difference properly (assuming that the fix can only be the one you've discovered so far, using Encode::encode_utf8 where necessary), how many times (in how many places) do you have:  use DBI;?

One approach would be to change that to something like:  use MyDBI;, and compose your module to inherit most of the functionality of DBI, but only replace the functions you use that actually return strings from the database. Your module would start with:

package MyDBI; @ISA = qw(DBI::db); use DBI;

Ideally, there would be some other, config-level change, like the mysql_enable_utf8 setting that you've already tried, that would make this approach unnecessary. But writing your own 'wrapper' module for DBI is a sensible and workable fallback.

BTW, if you can manage it, it may help to show us relevant bits of your code, so we see how you've done the DBI connect and a given query, plus snippets of actual data (preferably as Data::Dumper style output).

One other issue you didn't mention: are your old and new systems both talking to the same Mysql server, or was there an upgrade of that as well?


In reply to Re: UTF8 between versions by graff
in thread UTF8 between versions by edgreenberg

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.