Convert from unicode chars to HTML entities
Steven D'Aprano
steve at REMOVEME.cybersource.com.au
Sun Jan 28 22:05:24 EST 2007
I have a string containing Latin-1 characters:
s = u"© and many more..."
I want to convert it to HTML entities:
result =>
"© and many more..."
Decimal/hex escapes would be acceptable:
"© and many more..."
"© and many more..."
I can look up tables of HTML entities on the web (they're a dime a
dozen), turn them into a dict mapping character to entity, then convert
the string by hand. Is there a "batteries included" solution that doesn't
involve reinventing the wheel?
--
Steven D'Aprano
More information about the Python-list
mailing list