Decoding unicode from Javascript in Python & Django

On a website I have the word pluș sent via POST to a Django view. It is sent as plu%25C8%2599. So I took that string and tried to figure out a way how to make %25C8%2599 back into ș.

I tried decoding the string like this:

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

The result i get is pluÈ which actually has a length of 5, not 4.

How can I get the original string pluș after it's encoded ?


I managed to do it like this

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

It looks weird but works the way I needed it.


URL-decode twice, then decode as UTF-8.

Need Your Help

Share an image to specific apps

android eclipse android-image

I want to show a dialog with specific apps list and want to share my picture along with text message.

Assign Multiple Custom User Roles to a Custom Post Type

wordpress custom-post-type user-roles

Okay here's the situation.... I'm working on a my business website. There will be a work/portfolio area. "Work" is a custom post type. "Designer" is a custom user role. "Client" is a custom user ro...

Is there some license file in commercial joomla templates

design templates licensing joomla

I liked a commercial joomla template, and found a pirated copy of the same.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.