olivierp has asked for the wisdom of the Perl Monks concerning the following question:
use utf8; use strict; use DBI; use Win32::OLE; # Required to get Unicode correctly CP specifies Perl's "internal" enc +oding # LCID 65001 foces OLE to use (or stop translating) UTF8 # Beware that $variant->Time and $variant->Date will need an LCID in a +ddition # to the format string, e.g. 1033 for US English Win32::OLE->Option(CP => Win32::OLE::CP_UTF8, LCID => 65001); my $odbc_dsn = qq/driver={SQL Server};server=$database_name;AutoTransl +ate=OFF/; my $ado_oledb_dsn = <<EODSN; Provider=sqloledb; Data Source=$database_name; Integrated Security=SSPI EODSN my $sql =<<EOFSQL; select unicode_text from unicode_table where ut_id = 1 EOFSQL my $dbh = DBI->connect("dbi:ODBC:$odbc_dsn", "", ""); open FH, ">:utf8", "test_odbc.txt"; print FH ($dbh->selectrow_array($sql))[0]; close FH; $dbh->disconnect; $dbh = DBI->connect("dbi:ADO:$ado_oledb_dsn", "", ""); open FH, ">:utf8", "test_ado.txt"; print FH ($dbh->selectrow_array($sql))[0]; close FH; $dbh->disconnect; my $odbc_connection = Win32::OLE->new('ADODB.Connection'); $odbc_connection->Open($ado_oledb_dsn); my $recordset = Win32::OLE->new('ADODB.Recordset'); $recordset->Open($sql,$odbc_connection); open FH, ">:utf8", "test_ole.txt"; print FH $recordset->Fields(0)->Value; close FH; $odbc_connection->Close();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBD-ODBC: How to use Unicode on Win32 ?
by jZed (Prior) on Jul 16, 2004 at 17:44 UTC | |
by olivierp (Hermit) on Jul 16, 2004 at 19:51 UTC | |
|
Re: DBD-ODBC: How to use Unicode on Win32 ?
by Zaxo (Archbishop) on Jul 17, 2004 at 05:12 UTC |