Consider that Python will all one to type the name 'Jânis' into the Python CLI, if it is known that the 'â' character is hex "E2" in CP-1252:
>>> 'J\xe2nis'
'Jânis'
How might one type that name into the Python CLI if the Unicode code point is known, but not the CP-1252 point? In fact, the code point in question isU+00E2
. Also, the UTF-8 encoded character is %C3 %A2
, is there any way to type that into the Python CLI if only that is known?
I am using Python 3.2 on Kubuntu Linux 12.10.
Use unicode escape sequence (
\unnnn
):If you know utf-8, use
bytes.decode
(utf-8
is default encoding in Python 3.x, so it is optional):If you have
%C3%A2
, useurllib.parse.unquote
: