Monday, April 30, 2007

Python: unknown Encoding

I nearly pulled my hair out while trying to find the solution for this error:

LookupError: unknown encoding: cp720

FROM this following code fragment:

print "Name: ", objItem.Name

It was obvious, since my Windows System is an Arabic locale, with English default text, that I was surly to have some kind of problem.

I managed to find a lot of information regarding codecs, encoding, local, setlocale, etc. However, I managed to get it solved by using the str() function!

print "Name: ", str(objItem.Name)

Voi la..

7 comments:

Anonymous said...

Hi mate ...
Thank you for your comment.
you saved my day.

Wish you luck

Anonymous said...

Nice post, came in handy today. Thanks.

Anonymous said...

Thanks

Unknown said...

great!

Anonymous said...

Good words.

Sh7afana said...

eww.. i hate C++.. took the class and hated it.. sakheeeef

Hassan Mohamed said...

Thank you very much