469,628 Members | 1,012 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,628 developers. It's quick & easy.

convert html entities into real chars


Hi,

I would like to have a function that can convert '>' into '>',
'&' into '&' etc. I could not find how to do it easily (I have a
code snippet for the opposite).
Thanks,

Laszlo

Apr 10 '07 #1
2 1785
Laszlo Nagy wrote:
>
Hi,

I would like to have a function that can convert '>' into '>',
'&' into '&' etc. I could not find how to do it easily (I have a
code snippet for the opposite).
Thanks,

Laszlo
You can use htmlentitydefs module to help with this.

import htmlentitydefs

chr(htmlentitydefs.name2codepoint['gt'])

and (to go the other way)

htmlentitydefs.codepoint2name[ord('>')]

-Larry
Apr 10 '07 #2
Laszlo Nagy wrote:
>
Hi,

I would like to have a function that can convert '>' into '>',
'&' into '&' etc. I could not find how to do it easily (I have a
code snippet for the opposite).
Thanks,

Laszlo
You can use htmlentitydefs module to help with this.

import htmlentitydefs

chr(htmlentitydefs.name2codepoint['gt'])

and (to go the other way)

htmlentitydefs.codepoint2name[ord('>')]

-Larry
Apr 10 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by micha | last post: by
6 posts views Thread by Horst Gutmann | last post: by
3 posts views Thread by Himanshu Garg | last post: by
2 posts views Thread by Christian Reuter | last post: by
2 posts views Thread by Joergen Bech | last post: by
8 posts views Thread by Steven D'Aprano | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.