I'm writing some simple script to translate text to and from rot13. So inside the appriopriate class I have this:
def post(self):
dict = string.maketrans("ABCDEFGHIJKLMabcdefghijklmNOPQRSTUVWXYZnopqrstuvwxyz", "NOPQRSTUVWXYZnopqrstuvwxyzABCDEFGHIJKLMabcdefghijklm")
code = self.request.get("text")
code = string.translate(code, dict)
It gets the parameter "text" fine but at the .translate it blows up with internal server error:
File "<mypath>\main.py", line 46, in post
code = string.translate(code, dict)
File "C:\Python27\lib\string.py", line 498, in translate
return s.translate(table + s[:0])
UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 128: ordinal not in range(128)
What's wrong with my code?