How do I use non-ASCII strings in my Python script?
- string
- encoding
- unicode
- coding
- character
- character-set
Python cannot tell out of the box which character set your script uses, so you have to tell it.
The error you get is SyntaxError: Non-ASCII character '\xe2' in file bla.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
Like the link in the error message tells you, PEP-0263 defines the following syntax:
# coding: utf-8
In Python 2, you still have to use u'...'
strings to properly mark a string as Unicode.
The following questions generally talk about Unicode and UTF-8, but the same mechanism applies to any encoding other than ASCII, which is unambiguous and universal.