|Do you know where your variables are?|
DBD-ODBC: How to use Unicode on Win32 ?by olivierp (Hermit)
|on Jul 16, 2004 at 10:33 UTC||Need Help??|
olivierp has asked for the
wisdom of the Perl Monks concerning the following question:
I need to manipulate Unicode data stored in an MS SQL server, and would rather
use DBI + DBD::ODBC than my current Win32::OLE solution, for easier portability
(the scripts currently run on Win32, but could be moved to a Unix box...)
However, I am unable to correctly fetch from MSSQL's nvarchar, nchar and ntext fields
with DBI/DBD ODBC. I only get "??????" characters from the DB
I've included a small sample script that can be run to test this, provided you have non-ASCII values in the table.
test_odbc.txt contains this: ?????????
test_ole and test_ado.txt contains the correct value, a string in Japanese.
I am running this on WinXP / Win2k, with DBI 1.43 & DBD::ODBC 1.07 on Activestate perl 5.8.0
I have tried various DBI/DBD::ODBC combinations on As 5.8.0 & 5.8.3, but to no avail.
Has anyone encountered this and found a solution ?
I've found that DBD::ADO would be something to consider, as I found out it uses Win32::OLE itself, and thus can coerce Windows into using CP_UTF8 / 65001 as Codepage
Before trying this out deeper, I'm wondering what would happen if Win32::OLE were already initialized
by another script/module, before DBD::ADO gets called and changes the Codepage. I'm asking, as my data
access functions are actually stored in a package that I then include. Does anyone have tips/pointers for this ?