code: def _remove_invalid_char(s):
      
  
      s = ''.join([i if ord(i) >= 32 and ord(i) < 127 else '' for i in s])
      s = s.translate(dict.fromkeys(map(ord, "_%~#\\{}\":")))
      return s
docs: Remove invalid and dangerous characters from a string.