Opened 17 years ago
Closed 17 years ago
#5821 closed (wontfix)
Adds decode_entities to utils.html
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Tools | Version: | dev |
Severity: | Keywords: | html | |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This patch adds html entities decoding function to utils.html
Description
Replaces HTML entities (name, decimal and hexadecimal) with unicode equivalents.
Ampersands, quotes and carets are not replaced by default.
Usage
decode_entities can be used to normalize and store user input from a js html editor for example.
If you need to cut a string that could contain HTML entities, you can decode it before the cut without the fear of cutting through an entity.
Examples
>>> from django.utils.html import decode_entities >>> html = u'<Déjà 〈>' >>> decode_entities(html) u'<D\xe9j\xe0 \u2329>' >>> decode_entities(html, decode_all=True) u'<D\xe9j\xe0 \u2329>'
Attachments (2)
Change History (4)
by , 17 years ago
Attachment: | 5821_decode_entities.patch added |
---|
by , 17 years ago
Attachment: | 5821_decode_entities.2.patch added |
---|
decode_entities and test ( fixed regexp )
comment:1 by , 17 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 17 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
This is a good candidate for a custom template tag in a third-party app or library, but it's a bit too special case for Django proper.
decode_entities and tests