sophana schrieb: >>>> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position >> 3: ordinal not in range(128) >> > This is indeed the typical very annoying feature I was talking about. In > web application, these strings with unicode inside come from the web > requests. Why isn't the string class simply replaced by the unicode > class? Why 2 classes? Legacy. But please!!! There are NO "strings with unicode inside".
>> This is correct, since you tell python to add a Unicode-String to an >> Asc-String: There are NO "unicode strings" >> s += 'café' >> is the same as >> s = s + 'café' >> > Ok, but why is the right string encoded into ascii and not into the same > encoding as the left unicode string? There are NO "unicode strings". Unicode objects don't have encodings. > Isn't the += operator an unicode method? I guess unicode objects have __iadd__ defined, but the point here is: unicode objects and byte strings are two different data types! If you concat them, one of them gets encoded/decoded with the default encoding which happens to be ascii by default. If you have characters not in ascii, conversion will fail. The solution is: Know where you have byte strings and where you have unicode objects. If you have a form, parameters will be byte strings encoded with the encoding of the html page. The database stores byte strings and has an encoding as well. As a general rule you should use unicode objects in your program and know the boundaries where data comes in (forms) or gets serialized (database). Encode/decode at those boundaries and you are safe. cheers Paul ------------------------------------------------------------------------- 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 sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss