Changeset 7836 for django/branches/gis/django/utils/text.py
- Timestamp:
- 07/04/08 15:16:22 (6 months ago)
- Files:
-
- django/branches/gis (modified) (1 prop)
- django/branches/gis/django/utils/text.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/gis
- Property svnmerge-integrated changed from /django/trunk:1-7767 to /django/trunk:1-7835
django/branches/gis/django/utils/text.py
r7642 r7836 4 4 from django.utils.functional import allow_lazy 5 5 from django.utils.translation import ugettext_lazy 6 from htmlentitydefs import name2codepoint 6 7 7 8 # Capitalizes the first letter of a string. … … 223 224 smart_split = allow_lazy(smart_split, unicode) 224 225 226 def _replace_entity(match): 227 text = match.group(1) 228 if text[0] == u'#': 229 text = text[1:] 230 try: 231 if text[0] in u'xX': 232 c = int(text[1:], 16) 233 else: 234 c = int(text) 235 return unichr(c) 236 except ValueError: 237 return match.group(0) 238 else: 239 try: 240 return unichr(name2codepoint[text]) 241 except (ValueError, KeyError): 242 return match.group(0) 243 244 _entity_re = re.compile(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));") 245 246 def unescape_entities(text): 247 return _entity_re.sub(_replace_entity, text) 248 unescape_entities = allow_lazy(unescape_entities, unicode)
