Hi,

I have a similar utf conversion problem as discussed in
DBI (1.32, 1.37) transforms data before passing it to the driver? (XML and UTF-8 getting in the way?)


I have perl 5.8.0, linux, mysql 3.23.41, DBI 1.37.

I am reading an XML File using XML::XPath and want to store that data in mysql. The strings contain german umlaut characters.
Converting the strings with Unicode::String works for output to stdout, but passing it to DBI converts them back (?) to utf. Also the solution in the thread mentioned above does not work. Encode::Encode works too fine for screen output, but I still get the wrong charactes in my database. Testing the strings whith is_utf8 says flag is not set.


In detail :
...
# 1 my $insertstuff = join ", ", @insert_vals;
# 2 my $insertstuff = join ", ", map { Unicode::String::utf8($_)->latin1(); } @insert_vals;
# 3
my $insertstuff = join ", ", map {Encode::encode("iso-8859-1", Encode::decode("utf8",$_)) } @insert_vals;


if ( Encode::is_utf8($insertstuff) )
  {
    print "STUFF IS UTF8 $insertstuff\n";
    _utf8_off($insertstuff);
  }
else
  {
    print "STUFF IS NO UTF8 $insertstuff\n";
  }
...
  $dbh->do(qq{insert INTO $table ($inscols) VALUES($insertstuff)})

=================================
Running whith these 3 different conversions (2 always commented out) gives :

Line 1
print : STUFF IS NO UTF8 '184', 'AnschluÃ',
in DB : Anschluß

Line 2 and 3 are equal:
 print : STUFF IS NO UTF8 '178', 'Anschluß', ...
 in DB : Anschluß


Well now I don't know what to do. Help needed.





Reply via email to