On 9/10/06, paul kölle <[EMAIL PROTECTED]> wrote:
> Markus Gritsch schrieb:
> > On 9/10/06, Oleg Broytmann <[EMAIL PROTECTED]> wrote:
> >> On Sun, Sep 10, 2006 at 02:41:02PM +0200, Markus Gritsch wrote:
> >> > The following code worked in SQLObject-0.7.1b1 but raises an exception
> >> > when with SQLObject-0.7.1rc1:
> >> >
> >> > # -*- coding: latin-1 -*-
> >> >
> >> > from sqlobject import *
> >> >
> >> > sqlhub.processConnection =
> >> connectionForURI('mysql://[EMAIL PROTECTED]/test')
> >> >
> >> > class Test(SQLObject):
> >> >     name = UnicodeCol()
> >> >
> >> > Test.createTable(ifNotExists=True)
> >> > Test(name=u'sch?n')
> >>
> >> [skip]
> >>
> >> >     myquery = unicode(query, self.encoding)
> >> > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
> >> > 36: ordinal not in range(128)
> >>
> >>    self.encoding here is "ascii". Change the encoding:
> >>
> >> sqlhub.processConnection =
> >> connectionForURI('mysql://[EMAIL 
> >> PROTECTED]/test?sqlobject_encoding=latin1')
> >>
> >
> > Thank you for your help.  Yes, this prevents from the exception and
> > results in the same entry in the DB as when using 7.1b1.  However,
> > when using "MySQL Query Browser" one can see, that latin-1 is not
> > really what I want (attachment shot1.png).  I would like to save the
> > data utf-8 encoded (which would look like shot2.png), but when using
> >
> > sqlhub.processConnection =
> > connectionForURI('mysql://[EMAIL PROTECTED]/test?sqlobject_encoding=utf8')
> >
> [snipp traceback]
>
> Change your files encoding to utf-8 then.

No, this does not solve the problem.

> name=u'schön' is like unicode('schön', encoding) where "encoding" is
> eather sys.getdefaultencoding(), or what you wrote in your -*- coding:
> <> -*- statement.
>
> So to use u'something' you MUST be absolutely sure what the encoding of
> the file is. If the encoding of the file changes for whatever reason,
> your program will blow up.

Yes, I know, but
* specifying # -*- coding: latin-1 -*- at the beginning of the file
* having the file itself being stored in latin-1 8-bit encoding
* and using u'öäü'
is perfectly fine.

> BTW: utf8 is wrong. UTF-8 must always be represented as utf-8 or UTF-8.
> It is in the UTF-8 specification, and also RFCs 3629 and 2978.

I know, but you have to tell this the MySQL folks :)  They use utf8 as
the name for the UTF-8 encoding:
http://dev.mysql.com/doc/refman/5.0/en/charset-unicode.html

Kind regards,
Markus

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to