Re: Encoding/decoding: Still don't get it :-/

2009-03-16 Thread Antoon Pardon
On 2009-03-13, Johannes Bauer wrote: > Peter Otten schrieb: > >> encoding = sys.stdout.encoding or "ascii" >> for row in rows: >> id, address = row[:2] >> print id, address.encode(encoding, "replace") >> >> Example: >> > u"ähnlich lölich üblich".encode("ascii", "replace") >> '?hnlich

Re: Encoding/decoding: Still don't get it :-/

2009-03-16 Thread Gilles Ganault
On Fri, 13 Mar 2009 14:24:52 +0100, Peter Otten <__pete...@web.de> wrote: >It seems the database gives you the strings as unicode. When a unicode >string is printed python tries to encode it using sys.stdout.encoding >before writing it to stdout. As you run your script on the windows commmand >line

Re: Encoding/decoding: Still don't get it :-/

2009-03-15 Thread Johannes Bauer
Peter Otten schrieb: > encoding = sys.stdout.encoding or "ascii" > for row in rows: > id, address = row[:2] > print id, address.encode(encoding, "replace") > > Example: > u"ähnlich lölich üblich".encode("ascii", "replace") > '?hnlich l?lich ?blich' A very good tip, Peter - I've als

Re: Encoding/decoding: Still don't get it :-/

2009-03-13 Thread Peter Otten
Gilles Ganault wrote: > I must be dense, but I still don't understand 1) why Python sometimes > barfs out this type of error when displaying text that might not be > Unicode-encoded, 2) whether I should use encode() or decode() to solve > the issue, or even 3) if this is a Python issue or due to A

Encoding/decoding: Still don't get it :-/

2009-03-13 Thread Gilles Ganault
Hello I must be dense, but I still don't understand 1) why Python sometimes barfs out this type of error when displaying text that might not be Unicode-encoded, 2) whether I should use encode() or decode() to solve the issue, or even 3) if this is a Python issue or due to APWS SQLite wrapper that