Marek M.
Marek M.

Reputation: 3951

Urldecode GET parameter in django

I have a GET parameter of value Krak%F3w. It should be decoded as Kraków. I tried to urlunquote it, but when I try to print it to the console, I get this:

UnicodeEncodeError at /someurl.html

'charmap' codec can't encode character u'\ufffd' in position 4: character maps to <undefined>

And this:

Unicode error hint

The string that could not be encoded/decoded was: Krak�w

Upvotes: 1

Views: 3835

Answers (1)

mariodev
mariodev

Reputation: 15519

The encoding seems to be iso-8859-2, so you need to decode it:

url=urllib.unquote(url).decode('iso-8859-2') 

Upvotes: 3

Related Questions