mx odbc result strings with special characters?
Alexander Jerusalem
ajeru at vknn.org
Mon Mar 4 00:14:22 EST 2002
Hmm, ok, can you tell me how I can convert such a string back to the
ISO8859-1 character set so that I can write it to a text file?
The strange thing is, that when I read umlauts from a textfile and
print them to standard out, they remain intact. Only when they come
from the database driver are they converted to this hex
representation.
Alexander
"Fredrik Lundh" <fredrik at pythonware.com> wrote in message news:<TSug8.22747$n4.4298824 at newsc.telia.net>...
> 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 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