<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _delete_unwanted_caracters(self, chain):
 """Remove not wanted char from chain unwanted char are illegal_macro_output_chars attribute :param chain: chain to remove char from :type chain: str :return: chain cleaned :rtype: str """

        try:
            chain = chain.decode('utf8', 'replace')
        except UnicodeEncodeError:
            # If it is still encoded correctly, ignore...
            pass
        except AttributeError:
            # Python 3 will raise an exception because the line is still unicode
            pass
        for char in self.illegal_macro_output_chars:
            chain = chain.replace(char, '')
        return chain