Project

General

Profile

« Previous | Next » 

Revision 1761

strings.py: Added is_ctrl() and strip_ctrl()

View differences:

lib/strings.py
73 73
def single_space(str_): return re.sub(r' {2,}', r' ', str_.strip())
74 74

  
75 75
def one_line(str_): return re.sub(r'\n *', r' ', cleanup(str_))
76

  
77
##### Control characters
78

  
79
def is_ctrl(char):
80
    '''Whether char is a (non-printable) control character'''
81
    return ord(char) < 32 and not char.isspace()
82

  
83
def strip_ctrl(str_):
84
    '''Strips (non-printable) control characters'''
85
    return ''.join(filter(lambda c: not is_ctrl(c), str_))

Also available in: Unified diff