Quickie: converting r"\x2019" to int
Robin Haswell
rob at digital-crocus.com
Fri Apr 7 08:41:13 EDT 2006
> Therefore r'\x2019' is left unchanged, and cannot be converted to an
> int.
>
> Rob, this explains *why* you are getting the above error. It does not
> explain how to achieve your objective, as you have not specified what
> it is. If you give more information, one of the resident gurus may be
> able to assist you.
Thanks, I think that helps.
Basically I'm decoding HTML character references. "’" is a character
reference, equal to a single quote (ish).
http://ganesh.bronco.co.uk/example.html is the character in action. I want
to get from the string "x2019" to the Unicode character ’.
However, your help has lead me to a solution!
>>> u"\u2019"
u'\u2019'
>>> unichr(int("2019", 16))
u'\u2019'
>>>
That's got it - thanks :-)
-Rob
> Frank Millman’
More information about the Python-list
mailing list