2

Possible Duplicate:
Convert XML/HTML Entities into Unicode String in Python
Decode HTML entities in Python string?

I am using Python 2.7 and am fairly lost in unicode type. I looked up variety of help files and tutorials on it by I cannot get it actually working in the context I need. http://docs.python.org/howto/unicode.html

I have a library with names and it was saved decoded, ex. aaron's I need to encode the name into a user friendly manner Seems like basic answer to encoding

a ='aaron's,'
unicode(a)
a.encode('ascii', 'replace')

returns:

'aaron's,'

Which is not what I am looking for.

Community
  • 1
  • 1
rodling
  • 988
  • 5
  • 18
  • 44
  • See - http://stackoverflow.com/questions/57708/convert-xml-html-entities-into-unicode-string-in-python - http://stackoverflow.com/questions/701704/how-do-you-convert-html-entities-to-unicode-and-vice-versa-in-python –  Sep 10 '12 at 15:02

1 Answers1

4

You are looking for HTML entity decoding, not Unicode (or codec) decoding.

See Decode HTML entities in Python string? for ways to do this.

Community
  • 1
  • 1
nneonneo
  • 171,345
  • 36
  • 312
  • 383