Py3.3 unicode literal and input()
rosuav at gmail.com
Mon Jun 25 13:51:33 CEST 2012
On Mon, Jun 25, 2012 at 9:17 PM, jmfauth <wxjmfauth at gmail.com> wrote:
> Mea culpa. I had not my head on my shoulders.
> Inputing if working fine, it returns "text" correctly.
> However, and this is something different, I'm a little
> bit surprised, input() does not handle escaped characters
> (\u, \U).
> Workaround: encode() and decode() as "raw-unicode-escape".
It's the exact same thing. They're a backslash followed by a letter U.
However, if your stdin is set to (say) UTF-8, then bytes that
represent non-ASCII characters will be correctly translated,
eliminating any need for code-style escapes.
Allowing your users to put escaped Unicode characters into their input
opens up a huge morass - do they have to double every backslash? what
if they actually wanted "\", "u", etc? etc? etc?
More information about the Python-list