added unescapeHtmlString

This commit is contained in:
Darren Ranalli 2009-10-06 23:14:42 +00:00
parent 85fc649f2c
commit 23b4f51b43

View File

@ -32,7 +32,7 @@ __all__ = ['enumerate', 'unique', 'indent', 'nonRepeatingRandomList',
'pandaBreak','pandaTrace','formatTimeCompact','DestructiveScratchPad', 'pandaBreak','pandaTrace','formatTimeCompact','DestructiveScratchPad',
'deeptype','getProfileResultString','StdoutCapture','StdoutPassthrough', 'deeptype','getProfileResultString','StdoutCapture','StdoutPassthrough',
'Averager', 'getRepository', 'formatTimeExact', 'startSuperLog', 'endSuperLog', 'Averager', 'getRepository', 'formatTimeExact', 'startSuperLog', 'endSuperLog',
'typeName', 'safeTypeName', 'histogramDict', ] 'typeName', 'safeTypeName', 'histogramDict', 'unescapeHtmlString', ]
import types import types
import string import string
@ -4009,6 +4009,21 @@ def histogramDict(l):
d[e] += 1 d[e] += 1
return d return d
def unescapeHtmlString(s):
# converts %## to corresponding character
# replaces '+' with ' '
while 1:
try:
i = s.index('%')
except:
break
lastCharIndex = len(s)-1
if i <= lastCharIndex-2:
num = eval('0x' + s[i+1:i+3])
s = s[:i] + chr(num) + s[i+3:]
s = s.replace('+', ' ')
return s
import __builtin__ import __builtin__
__builtin__.Functor = Functor __builtin__.Functor = Functor
__builtin__.Stack = Stack __builtin__.Stack = Stack