code: def _encode_string(s):
          
          if six.PY2 and isinstance(s, unicode):
              return s.encode('utf-8')
          return s
docs: Encodes a unicode instance to utf-8. If a str is passed it will
          simply be returned
  
          :param s: str or unicode to encode
          :returns: encoded output as str