[Chicago] unicode -> xml

Michael Urman murman at gmail.com
Thu Feb 19 17:38:47 CET 2009


On Thu, Feb 19, 2009 at 10:23, Massimo Di Pierro
<mdipierro at cs.depaul.edu> wrote:
> problem. Given
>
>>>> a=chr(245).decode('latin-1').encode('utf8','xmlcharref')
>>>> print a
> õ
>
> how do I translate this into valid escaped XML "&U+xxxx;" in the general
> case?

Do you prefer something like
>>> c = chr(245).decode('latin-1')
>>> c.encode('ascii','xmlcharrefreplace')

Or something like
>>> '&U+%04X' % ord(c)

-- 
Michael Urman


More information about the Chicago mailing list