[Chicago] unicode -> xml
Cosmin Stejerean
cosmin at offbytwo.com
Thu Feb 19 17:39:02 CET 2009
On Thu, Feb 19, 2009 at 10:23 AM, 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?
>
reduce(lambda x,y: x + y[2:].upper(), map(lambda x: hex(ord(x)), a), '&U+')
--
Cosmin Stejerean
http://offbytwo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20090219/4b55f385/attachment.htm>
More information about the Chicago
mailing list