code: def ported_string(raw_data, encoding='utf-8', errors='ignore'):
      
  
      if not raw_data:
          return six.text_type()
  
      if isinstance(raw_data, six.text_type):
          return raw_data.strip()
  
      if six.PY2:
          try:
              return six.text_type(raw_data, encoding, errors).strip()
          except LookupError:
              return six.text_type(raw_data, "utf-8", errors).strip()
  
      if six.PY3:
          try:
              return six.text_type(raw_data, encoding).strip()
          except (LookupError, UnicodeDecodeError):
              return six.text_type(raw_data, "utf-8", errors).strip()
docs: Give as input raw data and output a str in Python 3
      and unicode in Python 2.
  
      Args:
          raw_data: Python 2 str, Python 3 bytes or str to porting
          encoding: string giving the name of an encoding
          errors: his specifies the treatment of characters
              which are invalid in the input encoding
  
      Returns:
          str (Python 3) or unicode (Python 2)