def ss(s, encoding=None, errors=u'strict'):
 encoding = (encoding or getEncoding())
 try:
  if isinstance(s, six.binary_type):
   if (encoding == u'utf-8'):
    return s
   else:
    return s.decode(u'utf-8', errors).encode(encoding, errors)
  if (not isinstance(s, six.string_types)):
   try:
    if six.PY3:
     return six.text_type(s).encode(encoding)
    else:
     return six.binary_type(s)
   except UnicodeEncodeError:
    return six.text_type(s).encode(encoding, errors)
  else:
   return s.encode(encoding, errors)
 except UnicodeEncodeError as e:
  print e
 return s

def ss ( s , encoding = None , errors = u'strict' ) : encoding = ( encoding or getEncoding ( ) ) try : if isinstance ( s , six . binary_type ) : if ( encoding == u'utf-8' ) : return s else : return s . decode ( u'utf-8' , errors ) . encode ( encoding , errors ) if ( not isinstance ( s , six . string_types ) ) : try : if six . PY3 : return six . text_type ( s ) . encode ( encoding ) else : return six . binary_type ( s ) except UnicodeEncodeError : return six . text_type ( s ) . encode ( encoding , errors ) else : return s . encode ( encoding , errors ) except UnicodeEncodeError as e : print e return s
converts basestring to sys_encoding .