On Thu, Jun 13, 2002 at 07:46:43PM +0200, Guillaume Rousse wrote:
> According to this thread
> http:[EMAIL PROTECTED]/msg10537.html, charset
> encoding is not a DBI issue, unless proven there is something wrong :-)
It used to not be a DBI issue because perl used to not support any concecpt
of characters encodings. Now perl supports UTF8 it's probably important for
drivers to set the relevant flag on the data when they return UTF8 strings.
Tim.
> This simple test case with DBI 1.25 and Pg driver 1.01 returns wrong
> characters with double utf8 conversion : the value "H�" from the database is
> transformed in "H􀀰礀" in the document. According to LibXML
> author, this happen when utf8 strings are not explictly marked as such.
>
> use DBI;
> use XML::LibXML;
> use strict;
>
> # global variables
> my $doc = new XML::LibXML::Document;
> my $root = $doc->createElement('authors');
> $doc->setDocumentElement($root);
>
> my $dbh = DBI->connect('DBI:Pg:dbname=olacacea;host=localhost;port=5432');
> my $sth = $dbh->prepare('SELECT * FROM authors ORDER BY index');
> $sth->execute();
>
> # get authors
> while (my $record = $sth->fetchrow_hashref()) {
> my $author = $doc->createElement('author');
> my $name = $doc->createElement('name');
> my $name_text = $doc->createTextNode($record->{name});
> $name->appendChild($name_text);
> $author->appendChild($name);
> $author->setAttribute('id', $record->{index});
> $root->appendChild($author);
> }
>
> $sth->finish();
> --
> Guillaume Rousse <[EMAIL PROTECTED]>
> GPG key http://lis.snv.jussieu.fr/~rousse/gpgkey.html