code: def s(self, data, errors='strict'):
          
          try:
              if data is None or isinstance(data, (int, list, dict)):
                  pass  # Do nothing with these types
              elif isinstance(data, unicode):
                  try:
                      data.decode('utf-8')
                  except UnicodeEncodeError:  # 2to3 converts unicode to str
                      # 2to3 converts unicode to str
                      data = str(data.encode('utf-8').strip(), errors=errors)
                      self.log.warning(u'Encoding poorly encoded string ({})'.format(data))
                  except AttributeError:
                      pass  # Python 3 can't decode a str
              else:
                  data = str(data, 'utf-8', errors=errors)  # 2to3 converts unicode to str
          except NameError:
              pass  # Can't decode str in Python 3
          return data
docs: Decode value using correct Python 2/3 method.
  
          This method is intended to replace the :py:meth:`~tcex.tcex.TcEx.to_string` method with
          better logic to handle poorly encoded unicode data in Python2 and still work in Python3.
  
          Args:
              data (any): Data to ve validated and (de)encoded
              errors (string): What method to use when dealing with errors.
  
          Returns:
              (string): Return decoded data