From 23b4f51b4381a0f12a69b144cb5ac9e067e46ac2 Mon Sep 17 00:00:00 2001 From: Darren Ranalli Date: Tue, 6 Oct 2009 23:14:42 +0000 Subject: [PATCH] added unescapeHtmlString --- direct/src/showbase/PythonUtil.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/direct/src/showbase/PythonUtil.py b/direct/src/showbase/PythonUtil.py index 782ce456fe..a288253ba1 100644 --- a/direct/src/showbase/PythonUtil.py +++ b/direct/src/showbase/PythonUtil.py @@ -32,7 +32,7 @@ __all__ = ['enumerate', 'unique', 'indent', 'nonRepeatingRandomList', 'pandaBreak','pandaTrace','formatTimeCompact','DestructiveScratchPad', 'deeptype','getProfileResultString','StdoutCapture','StdoutPassthrough', 'Averager', 'getRepository', 'formatTimeExact', 'startSuperLog', 'endSuperLog', -'typeName', 'safeTypeName', 'histogramDict', ] +'typeName', 'safeTypeName', 'histogramDict', 'unescapeHtmlString', ] import types import string @@ -4009,6 +4009,21 @@ def histogramDict(l): d[e] += 1 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__ __builtin__.Functor = Functor __builtin__.Stack = Stack