possible problem with unicode_results = 1
Karsten Hilbert <[email protected]> Tue, 29 Aug 2006 13:37:10 +0200
| Newsgroups | gmane.comp.python.db.pypgsql.user |
|---|---|
| Message-ID | <[email protected]> |
Hello community, I am not sure I understand how unicode_results is supposed to work right: Assume this: - client_encoding is set to 'iso8859-1' at the connect() level - hence "set client_encoding" must also be set to 'iso8859-1' at the SQL level - thereby, strings *returning* from the database are encoded as 'iso8859-1', too, when they enter pyPgSQL from libpq - now I want to have results in unicode - hence I set unicode_results=1 at the connect() level - thereby string-types are passed to unicode() in pyPgSQL without further arguments as per the code - hence unicode() uses the default encoding as per Python docs - which in most cases is "ascii" - bad things happen Really, the client_encoding value should be passed in to unicode() as well, shouldn't it ? Or is my logic flawed ? No, it is not always possible to set the Python default string encoding to something sane as would seem prudent to do. It is not recommended to do so, either. Karsten -- GPG key ID E4071346 @ wwwkeys.pgp.net E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346 ------------------------------------------------------------------------- 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