From: Karsten H. <Kar...@gm...> - 2006-08-29 11:37:21
|
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 |