>
> I am having some character-set problems with SQLObject and MySQLdb
> within a turbogears project.
>
> my dsn:
> sqlobject.dburi="notrans_mysql://user:pass@localhost/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.