We have recently upgraded our system (Debian woody) from Perl 5.6.1 to Perl 5.8. We have a content management system that makes heavy use of XML. However, there are occasions where we want to put iso in our mysql database, and sometimes we want XML. We have worked around some caveats when upgrading, but this one is a miracle for me:

I have a CGI script for a user interface to update some database stuff. This is a generig script which gets an XML config file where the database tables and fields to update/insert are defined. This file is processed by XML::Parser, and the web form and insert/update/select statements are thus dynamically constructed (in a rather comlicated way). In this case we want ISO in the database.

However, there is the following problem: In 5.6.1 everything worked fine, but now with 5.8. we unexpectedly get unicode in the database when we use DBI!

Like this:
use FW::Database; use XML::Parser; . .# a lot of stuff that constructs $stmt . DB_insertdata($stmt, $dbh);
where DB_insertdata is (among other things) in FW::Database:
package FW::Database; require Exporter; use vars qw(@ISA @EXPORT %conf); @ISA = qw(Exporter); @EXPORT = qw( &DB_insertdata ); sub DB_insertdata { my $stmt = $_[0]; my $dbh = $_[1]; my $error = ""; my $sth = $dbh->prepare($stmt) || FW::Utils::handle_dberror("$DBI: +:errstr", $dbh); my $rv = $sth->execute() || FW::Utils::handle_dberror("$DBI::errst +r", $dbh); }
When printing $stmt either into the browser or via STDERR in the error.log everything is ISO, but when the same string is inserted via DBI I get unicode in the database! So, the current urgency workaround is forget agbout DBI and replacing DB_insertdata with
open (PIPE, "|/usr/local/mysql/bin/mysql -u user database"); print PIPE $stmt; close(PIPE);
which works but is of course very far away from being acceptable code.

I am sorry that this got so lengthy. Nevertheless I hope that anyone can provide clues to that. thank you Karlheinz

In reply to Perl 5.8, DBI and unicode by Anonymous Monk

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.