I'm developing a cgi-bin application that must be unicode sensitive. I'm striving for a UTF8 implementation. I'm running python 2.3 on a development machine (windows xp) and a server (windows xp server). Both environments are running Apache 2.2 with the same configuration file.

The problem is this. On my development machine I get the following unicode error:

UnicodeDecodeError: 'utf8' codec can't decode bytes in position 4-6: invalid data
args = ('utf8', 'adem\xe3\xa1s', 4, 7, 'invalid data')
encoding = 'utf8'
end = 7
object = 'adem\xe3\xa1s'
reason = 'invalid data'
start = 4

On my server, running exactly the same python code, I see the following unicode error:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 4: ordinal not in range(128)
args = ('ascii', 'adem\xe3\xa1s', 4, 5, 'ordinal not in range(128)')
encoding = 'ascii'
end = 5
object = 'adem\xe3\xa1s'
reason = 'ordinal not in range(128)'
start = 4

Note the differences in the encoding -- on the development machine it's utf8 but on the server it's ascii.

I thought Python assumed ascii encoding by default. How did my development machine get to be utf8? And since my python code is the same on both machines, what is it about my configuration that could be causing a difference in default encoding?

Thanks in advance.

9 Years
Discussion Span
Last Post by Ene Uran
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.