'Restricts the characters that are allowed in a text'

def sanitize_text(self, text):

    if (not self.sanitize):
        return text
    rval = []
    for c in text:
        if (c in self._valid_chars):
            rval.append(c)
        elif (c in self._mapped_chars):
            rval.append(self._mapped_chars[c])
        else:
            rval.append(self._invalid_char)
    return ''.join(rval)
