Long way around UnicodeDecodeError, or 'ascii' codec can't decode byte

Jarek Zgoda jzgoda at o2.usun.pl
Sat Mar 31 06:41:46 EDT 2007


Oleg Parashchenko napisał(a):

>>> I spent two hours fixing it, and I hope it's done. The solution is one
>>> of the ugliest hack I ever written, but it solves the pain. The full
>>> story and the code is in my blog:
>>> http://uucode.com/blog/2007/03/23/shut-up-you-dummy-7-bit-python/
>> Calling sys.setdefaultencoding might not even help in this case, and
>> the consensus is that it may be harmful to your code's portability
>> [1].
> 
> Yes, but I think UTF-8 is now everywhere.

No, it is not. Your own system is "not ready for UTF-8", as you stated
somewhere in this blog entry. How can you expect everybody else's system
being utf-8, while "you are not ready for transition"?

It would be better if you write your programs in encoding-agnostic way,
using byte streams only for input and output (yes, printing a debug
statement on terminal *is* a kind of producing the output). An, oh, you
cann't encode/decode text not knowing the encoding...

-- 
Jarek Zgoda
http://jpa.berlios.de/



More information about the Python-list mailing list