Hello,

I read that some people have problem with unicode and sqlobject.
I never had problem until I upgrade to version 0.8 . I did not try to
figure out how the problem occurs yet (and why it did not occur with
older version), but I have changed two lines in col.py that solves it:

===================================================================
--- col.py      (revision 1824)
+++ col.py      (working copy)
@@ -513,7 +513,7 @@
        if value is None:
            return None
        if isinstance(value, unicode):
-           return value.encode("ascii")
+           return value.encode("utf-8")
        return value

    def from_python(self, value, state):
@@ -522,7 +522,7 @@
        if isinstance(value, str):
            return value
        if isinstance(value, unicode):
-            return value.encode("ascii")
+            return value.encode("utf-8")
        return value

class SOStringCol(SOStringLikeCol):
===================================================================

A unicode value seems to be validated by StringValidator and it tries
to encode it in ascii.
While this unicode string should maybe not be validated by
StringValidator I think that it is preferable to encode in utf-8 by
default since utf-8 contains ascii. By the way, I also think that
encoding in ascii (if it makes sense) shall always be done in a try
catch.

--
jt

Attachment: col.py.diff
Description: Binary data

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