decoding XML-ified special chars such as "
Christopher
chris_mk at hotmail.com
Tue Jul 30 18:14:35 EDT 2002
Well, I seem to remember seeing something else, but here is what I
got...
Look in the HTMLParser.HTMLParser class for the function unescape...
def unescape(self, s):
if '&' not in s:
return s
s = s.replace("<", "<")
s = s.replace(">", ">")
s = s.replace("'", "'")
s = s.replace(""", '"')
s = s.replace("&", "&") # Must be last
return s
That's it. Looks like it was just a string substitution like I
mentioned earlier to Gabe in an email. I'm actually pretty sure there
is another way somewhere, I just can't remember where. Sorry.
Chris
PS you can use it as follows:
>>> import HTMLParser
>>> test = HTMLParser.HTMLParser()
>>> test.unescape('abc < def')
'abc < def'
"Gabe Newcomb" <Gabe.Newcomb at noetix.com> wrote in message news:<mailman.1027968580.20805.python-list at python.org>...
> Is there a module to take strings such as ", & and turn them
> into the characters they normally represent (', &)?
>
> Gabe Newcomb
> Software Test Automation Engineer
> 425.372.2732
> Noetix Corporation
> www.noetix.com
>
> after years of waiting, nothing came
More information about the Python-list
mailing list