code: def ConvertStringToFilename(name):
    
    return re.sub(
        r"\W", lambda x: "%%%02X" % ord(x.group(0)), name,
        flags=re.UNICODE).rstrip("/")
docs: Converts an unicode string to a filesystem safe filename.
  
    For maximum compatibility we escape all chars which are not alphanumeric (in
    the unicode sense).
  
    Args:
     name: a unicode string that is part of a subject.
  
    Returns:
      A safe filename with escaped special chars.