I am a newcomer to Apache in general, since I have only began Web Developing, so please request for additional particulars basically haven't provided enough.

I'm while using out-from the box Apache that ships with Lion, and that i have produced a Python application that, every every now and then, must print a UTF-8 character.

However, regardless of what method I personally use, or just how much I attempt, whenever I attempt to print a UTF-8 character, it'll get rid of a 500 Internal Server Error, and I'll be playing nothing.

The different things I have attempted:

  • Making the smoothness from the Python code (Using the # -*- coding: utf-8 -*- towards the top of the code.)
  • Making the smoothness while using .decode('utf-8') function. (Which leads to making 3 seperate figures.)
  • Making a placeholder, after which making Jquery which may replace the placeholder using the Symbol (And also the page throws up an interior Server Error)
  • Making a placeholder, after which making a hyperlink to some Jquery script which may change it. (Firebug states that Opera will get a 500 Server Error when attempting to gain access to the script.)

I am unable to think about other things. This is exactly why I have requested here.

Any suggestions?

Thanks ~DragonXDoom

EDIT: After testing out Will's suggestion below, Now i obtain the following error.

<type 'exceptions.UnicodeDecodeError'>: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)
  args = ('ascii', '\xe2\x80\xa2', 0, 1, 'ordinal not in range(128)')
  encoding = 'ascii'
  end = 1
  message = ''
  object = '\xe2\x80\xa2'
  reason = 'ordinal not in range(128)'
  start = 0 

You have to read http://www.joelonsoftware.com/articles/Unicode.html to ensure that you've some knowledge of the overall problem.

Once you have understood that, then you definitely should learn to handle unicode properly in Python, I believe the next website ought to be helpful, although extended: http://boodebr.org/main/python/all-about-python-and-unicode

Anything you do, please NOT skimp or skip on understanding unicode - otherwise you will keep to possess subtle issues.

In addition, you condition that you have tried to use .decode('utf-8') - this will not work if python has /already/ understood the information as unicode - you need to scribe it!

To elaborate on my small comment, you are able to tell the browser which encoding the page has been sent either in by having an HTTP header:

Content-type: text/html; charset=UTF-8

or by having an equivalent <meta> tag (which matches within the <head> section inside your HTML):

<meta http-equiv="Content-type" value="text/html; charset=UTF-8" />

By doing this it should properly interpret the UTF-8 figures it receives. (text/html could be changed having a appropriate MIME type.)

For the very first attempt, with # -*- coding: utf-8 -*-, I expect the reason being Apache does not understand how to interpret UTF-8 source files.

Again, I am not necessarily acquainted with running Python on Apache, but maybe this is of outside assistance!