Added escaping of unicode text input of ASCII control characters and extended characters as per #551.

This commit is contained in:
Griatch 2014-08-21 08:52:49 +02:00
parent 8afdbc6adb
commit 4e2dfef321
2 changed files with 9 additions and 2 deletions

View file

@ -1095,3 +1095,10 @@ class lazy_property(object):
value = self.func(obj)
obj.__dict__[self.__name__] = value
return value
_RE_CONTROL_CHAR = re.compile('[%s]' % re.escape(''.join([unichr(c) for c in range(0,32) + range(127,160)])))
def escape_control_sequences(string):
"""
remove non-print text sequences from string.
"""
return _RE_CONTROL_CHAR.sub('', string)