Decoding unicode from Javascript in Python & Django -


on website have word pluș sent via post django view. sent plu%25c8%2599. took string , tried figure out way how make %25c8%2599 ș.

i tried decoding string this:

from urllib import unquote_plus s = "plu%25c8%2599" print unquote_plus(unquote_plus(s).decode('utf-8')) 

the result pluÈ has length of 5, not 4.

how can original string pluș after it's encoded ?

edit:

i managed this

def js_unquote(quoted):   quoted = quoted.encode('utf-8')   quoted = unquote_plus(unquote_plus(quoted)).decode('utf-8')   return quoted 

it looks weird works way needed it.

url-decode twice, then decode utf-8.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -