def _percent_encode(encode_str):
 encoding = (sys.stdin.encoding or 'cp936')
 decoded = str(encode_str)
 if PY3:
  if isinstance(encode_str, bytes):
   decoded = encode_str.decode(encoding)
 else:
  decoded = str(encode_str).decode(encoding)
 res = urlquote(decoded.encode('utf8'), '')
 res = res.replace('+', '%20')
 res = res.replace('*', '%2A')
 res = res.replace('%7E', '~')
 return res

def _percent_encode ( encode_str ) : encoding = ( sys . stdin . encoding or 'cp936' ) decoded = str ( encode_str ) if PY3 : if isinstance ( encode_str , bytes ) : decoded = encode_str . decode ( encoding ) else : decoded = str ( encode_str ) . decode ( encoding ) res = urlquote ( decoded . encode ( 'utf8' ) , '' ) res = res . replace ( '+' , '%20' ) res = res . replace ( '*' , '%2A' ) res = res . replace ( '%7E' , '~' ) return res
encode string to utf8 .