>
> I am having some character-set problems with SQLObject and MySQLdb
> within a turbogears project.
>
> my dsn:
> sqlobject.dburi="notrans_mysql://user:[EMAIL PROTECTED]/database?
> charset=utf8&debug=True"
>
> my class:
> class aTest(SQLObject):
> class sqlmeta:
> table="atest_test"
>
> name=UnicodeCol(length=100)
>
> in the shell:
> >>> aTest(name="abc")
>
> <aTest 1L name=u'abc'>
>
> #this one was alright BUT:
>
> >>> meinTest(name="äöü") # causes:

IMHO, This should work. My bet would be that your editor or console uses an
encoding different from utf-8. My editor, for example, encodes in latin-1,
and latin-1's äöüs are NOT encoded the same as in utf-8. So,
'äöü'.decode('utf-8') yields an error in my console.

You could also specify the editor's encoding by setting this line on top of
your source files:

# -!- encoding: latin-1 -!-

And then use unicode strings directly:

meinTest(name=u"äöü")

In my experience, this is the safest way of handling string encoding in
python. The downside is that you cannot do "print u'äöü'", since python
tries to encode it to ASCII, which has no place for german umlauts at all.

HTH
Bernhard

___________________________________________________________________

Disclaimer:


Diese Mitteilung ist nur fuer die Empfaengerin / den Empfaenger bestimmt.

Fuer den Fall, dass sie von nichtberechtigten Personen empfangen wird,
bitten wir diese hoeflich, die Mitteilung an die ZKB zurueckzusenden und
anschliessend die Mitteilung mit allen Anhaengen sowie allfaellige Kopien
zu vernichten bzw. zu loeschen. Der Gebrauch der Information ist verboten.


This message is intended only for the named recipient and may contain
confidential or privileged information.

If you have received it in error, please advise the sender by return e-mail
and delete this message and any attachments. Any unauthorised use or
dissemination of this information is strictly prohibited.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to