code: def to_utf8(str_or_unicode):
      
      if not isinstance(str_or_unicode, six.text_type):
          return str_or_unicode.encode("utf-8", "ignore")
      return str(str_or_unicode)
docs: Safely returns a UTF-8 version of a given string
      >>> utils.to_utf8(u'hi')
          'hi'