mx odbc result strings with special characters?
Bengt Richter
bokr at oz.net
Mon Mar 4 01:26:13 EST 2002
On Sun, 03 Mar 2002 19:32:03 GMT, "Fredrik Lundh" <fredrik at pythonware.com> wrote:
>Alexander Jerusalem wrote:
>
>> Ok, thanks for your reply. Here's my output:
>>
>> >>> import mx.ODBC.Windows as odbc
>> >>> con = odbc.connect("se", "scienceexile", "x")
>> >>> c = con.cursor()
>> >>> c.execute("select * from country")
>> >>> print c.fetchone()
>> ('aa1', '\xd6sterreich-Ungarn', None, None)
>> >>> c.close()
>> >>> con.close()
>>
>> And it's the same when I write the resultset to a file, so I don't
>> believe that it's just a display problem.
>
>on the other hand:
>
>>>> print '\xd6sterreich-Ungarn'
>Österreich-Ungarn
>
More illustration (clipped from IDLE with 2.1) using
example data from above:
>>> print ('aa1', '\xd6sterreich-Ungarn', None, None)
('aa1', '\xd6sterreich-Ungarn', None, None)
>>> print ('aa1', '\xd6sterreich-Ungarn', None, None)[1]
Österreich-Ungarn
and
>>> oe = ('aa1', '\xd6sterreich-Ungarn', None, None)[1][0]
>>> print oe, `oe`, str(oe), repr(oe), (oe, hex(ord(oe)))
Ö '\xd6' Ö '\xd6' ('\xd6', '0xd6')
^^^^^^
I.e., it's not the data character, it's the presentation
that depends on context here.
HTH
Regards,
Bengt Richter
>more info here:
>
> http://www.python.org/doc/current/tut/node5.html
>
> "The interpreter prints the result of string operations in the
> same way as they are typed for input: inside quotes, and
> with quotes and other funny characters escaped by back-
> slashes, to show the precise value"
>
> http://www.python.org/doc/current/ref/strings.html
> http://www.python.org/doc/current/ref/exprstmts.html
> http://www.python.org/doc/current/ref/print.html
> (etc)
>
></F>
>
><!-- (the eff-bot guide to) the python standard library:
>http://www.pythonware.com/people/fredrik/librarybook.htm
>-->
>
>
More information about the Python-list
mailing list