[Grok-dev] UnicodeDecodeError

Steve Schmechel steveschmechel at yahoo.com
Thu Jul 23 09:55:13 EDT 2009


I am having a problem where a certain piece of code works fine on my computer with UTF-8 encoding, but not on one using cp1250 encoding.

I am handing everything as unicode internally.

There might be a simple answer to this, but even after reading through much discussion on unicode in Python, I can't seem to figure this out.

The code on the Grok.Model based class:
timezone= unicode(time.strftime("%Z", time.localtime()))

The code in the page template:
Timezone: <span tal:content="python:context.timezone">TimeZone</span>

(The idea is to display the server timezone so the user can understand the dates assigned to posted comments.  I'm not interested in trying to localize the time display of individual comments.)

When run on a Linux-based computer in the USA this works fine.
When run on a Windows Vista computer in Poland the same code returns:
"UnicodeDecodeError: 'ascii' codec can't decode byte 0x8c in position 0: ordinal not in range(128)"

If the user in Poland views the same application running on my computer it is fine.  I can not access the code running on his computer.
This is hard for me to reproduce and debug.
I'm sure others have dealt with this type of problem before.
What is the best approach to avoid this error?


Thanks,
Steve


-------
Server process info
 from computer in Poland:
 

Uptime: 

0 day(s) 00:00:56 

System platform: 

Windows Dudu 32bit 

Zope version: 

Development/Unknown 

Python version: 

2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] 

Command line: 

C:\virtualgrok\music\bin\paster-script.py serve parts\etc\deploy.ini 

Preferred encoding: 

cp1250 

File system encoding: 

mbcs 


      


More information about the Grok-dev mailing list