I am trying to write a simple CGI script with Python 3 that will print the string "MÅDRS" (note the Å). The following code works fine:
print("Content-type: text/html")
print("\n")
print("Test")
However, when I attempt to print "MÅDRS" instead of "Test" I receive the following error:
Traceback (most recent call last):
File "index.cgi", line 69, in <module>
File "index.cgi", line 51, in main
File "/usr/local/lib/python3.0/io.py", line 1494, in write
b = encoder.encode(s)
File "/usr/local/lib/python3.0/encodings/ascii.py", line 22, in encode
return codecs.ascii_encode(input, self.errors)[0]
UnicodeEncodeError: 'ascii' codec can't encode character '\xc5' in position 1: ordinal not in range(128)
Is there a simple solution to this problem? I have been researching for several hours but can't seem to find it.