in reply to DBI handling special chars like accented ones

The patch randyk linked should solve it, assuming everything else is fine; but to actually understand what that “bunch of junk” is, read The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!).

Makeshifts last the longest.

  • Comment on Re: DBI handling special chars like accented ones

Replies are listed 'Best First'.
Re^2: DBI handling special chars like accented ones
by RnC (Sexton) on Jan 09, 2006 at 22:56 UTC
    I feel like I'm punching nails here =(

    This is what I've tried so far:
    - The patch suggested by randyk. I downgraded DBD::mysql to version 2.9008 to be able to apply it.
    - rebuilding the database AND the tables setting the default charset to utf8.
    - using the Encode module to encode a string to utf8 similar to what is suggested here.

    None of the above worked, as I'm still getting "junk" when trying to INSERT via DBI. And it has to be either the module or maybe some missing locale setting (I've tried changing it as well with Posix locale_h, but no success), since I can perform INSERTs via the MySQL shell using accents just fine.

    Any help is appreciated.
      Ok, I found out a solution.

      The patch mentioned on the parent post has no effect for this particular case. I rolled back to DBD-mysql-3.0002. Actually, the fix consists of using the utf8 pragma, and then performing an upgrade in the string, like this:

      use utf8; ... my $string = "voilá monsieur"; utf8::upgrade($string); # $string is now ready to be INSERTed by DBI, # but you still need to do this $dbhandle->do("SET CHARACTER SET utf8"); # now you can perform the INSERT