Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using python code to encode text before inserting into a database in a remote server (linux). Since I have special characters so I need to encode them to unicode. But I got following error while encoding text.

UnicodeDecodeError: 'ascii' codec can't decode byte 0xf8 in position 2: ordinal not in range(128)

my code is:

        for item in dict.iteritems():
             name = item[0].encode('UTF-8') --  error in this line

What does this mean? Why this works in WIndows7 and not in Linux ? I am very new to linux, so did not understand the way it worked differently in windows7 and linux.

share|improve this question

It means that the key is already encoded, and the system is attempting to decode it first before the encode operation.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.