On 2006-04-17, <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote:
> Hi All,
> I've done a bunch of searching in google and in python's help, but,
> I haven't found any function to decode a string like:
> Refresh&#33; (ihenvyr)
> In to plain english.
> [...]

I needed to do that the other day, and did it like this:

def decode(line):
        pat = re.compile(r'&#(\d+);')
        def sub(mo):
                return unichr(int(mo.group(1)))
        return pat.sub(sub, unicode(line))

there may well be a better way though.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to