Oh! Well, that means that it is $dbh->quote(...) that is hosing your data. I would really recommend that you look into using binds for your dynamic literals rather than quoting them.

If you are not familiar with binds (or "placeholders", depending on the documentation source), then you should really look into them. The basic idea is that, instead of doing this:

my $quotedvar = $dbh->quote($var); my $sql = "insert into mytable (mycolumn) values ($quotedvar)"; $dbh->do($sql);
do this:
my $sql = "insert into mytable (mycolumn) values (?)"; $dbh->do($sql,undef,$var);
But you should definiftely consult the DBI docs for more info on this (see the section under "Placeholder and Bind Values").

I'm really not at all surprised that $dbh->quote(...) is mangling your data, because, well, that's what its job is, and apparently it is just getting a little bit over-zealous with its mangling. More to the point, it may not be character-encoding-aware... wheras simply binding the value just passes it directly through to the DBD. And, in the case of mysql, the DBD is probably capable of handling character-encoding well, since there is explicit functinoality around it in the database.


------------
:Wq
Not an editor command: Wq

In reply to Re: Re: Re: Perl Mysql and UTF8 by etcshadow
in thread Perl Mysql and UTF8 by emilioayllon

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.