I'm having Unicode-related problems with pyodbc.
I can connect to my database and run queries without issue. I can
SELECT numeric values and use the results without problems but when I
select varchar fields, the results are scrambled.
For example, given the following query:
SELECT countyname FROM county_db WHERE countyname='ADAMS' LIMIT 1
I should get a single item containing the text "ADAMS". But instead, I
get the following:
u'\u4441\u4d41S\u3139\ud580'
The hex values for "ADAMS" are 41 44 41 4d 53. The above Unicode hex
contains these ASCII hex values plus some additional junk values. For
clarity, see below:
\u4441 => 44 (D), 41 (A)
\u4d41 => 4d (M), 41 (A)
S => S
\u3139 <- junk data from adjacent memory address
\ud580 <- junk data from adjacent memory address
I saw Daniel Holth's post <
http://groups.google.com/group/pyodbc/msg/
7ba109cd82eab4ac> and added '-fshort-wchar' to setup.py's
extra_compile_args and reinstalled pyodbc, but this didn't change the
behavior noted above.
I've been at this for a while and I'm out of ideas. Can anyone help?
Suggestions are welcome.
P.S. I'm using Python 2.6.4 compiled with the default UCS2 option.