[egenix-users] Enabling unicode?

Chuck Bearden cfbearden at gmail.com
Wed Oct 27 17:37:59 CEST 2004


On Wed, 27 Oct 2004 21:51:04 +0200, M.-A. Lemburg <mal at egenix.com> wrote:
> Chuck Bearden wrote:
> 
> > I have been having unicode problems from time to time with mx.ODBC,
> > libiodbc (3.51.2), and FreeTDS (0.63.dev.20041026 at the moment) on
> > some recent flavor of free Red Hat.
> >
> > Being a little slow on the uptake, I only just noticed that there is a
> > constant HAVE_UNICODE_SUPPORT.  I just checked it:
> >
> > $ python
> > Python 2.3.3 (#1, Apr 12 2004, 14:00:40)
> > [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> >
> >>>>import mx.ODBC.iODBC
> >>>>mx.ODBC.iODBC.HAVE_UNICODE_SUPPORT
> >
> > 0
> >
> >
> > When I grep out all lines "^#" from mx/ODBC/iODBC/Setup.in, I get this:
> >
> > *shared*
> >
> >
> > mxODBC  mxSQLCodes.c mxODBC.c \
> >         -DMAL_DEBUG \
> >         -DWANT_UNICODE_SUPPORT \
> >         -DMISSING_SETUP
> >
> >
> > which is I think the default.  So, although I wanted Unicode, I didn't get it.
> >
> > Did I fail to build iODBC or FreeTDS in such a way as to enable
> > mx.ODBC to define HAVE_UNICODE?  Or did I do something else wrong?
> 
> If you compile the package with the setup.py apporach,
> edits to Setup or Setup.in don't have any effect.
> 
> Default for iODBC is not to build with Unicode support,
> whereas it is always enabled for unixODBC.
> 
> Nowadays, it is safe to enable Unicode for both.
> 
> In order to enable it for iODBC as well, you have to edit
> mxCOMMERCIAL.py and add the WANT_UNICODE_SUPPORT define
> there.

Thank you for your reply.  Sorry to be so dense, but I don't seem to
be able to figure this out.  I modified the Extension() definition for
iODBC in mxCOMMERCIAL.py like so:

Extension('mx.ODBC.iODBC.mxODBC',
          ['mx/ODBC/iODBC/mxODBC.c',
           'mx/ODBC/iODBC/mxSQLCodes.c'
           ],
          include_dirs=['mx/ODBC/iODBC',
                        '/usr/local/libiodbc/include'],
          define_macros=[('iODBC', None), ('WANT_UNICODE_SUPPORT', 1)],
          library_dirs=['/usr/local/libiodbc/lib'],
          libraries=['iodbc']
          ),

that is, I modified the paths to my iODBC libs and includes, and I
added 'WANT_UNICODE_SUPPORT' to the define_macros list (I tried with
values of None and 1).  I build with

  python setup.py install --home=/home/cbearden/opt

I get this:

[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path= ['/home/cbearden/opt/lib/python'] + sys.path
>>> import mx.ODBC.iODBC as mxodbc
>>> mxodbc.HAVE_UNICODE_SUPPORT
0
>>>

Just to be absolutely certain I was using the module I had just built,
I modified __version__ in mx/ODBC/ODBC.py (added '-foo'' to the
string) and checked it from within the same interactive shell.

Surely I am doing some simple thing wrong such that I am not getting
Unicode support.

Chuck



More information about the egenix-users mailing list