3

I have a search form in my app that uses a jQuery autocomplete plugin. The plugin sends over the suggested item after running the querystring through encodeURI(q).

So an item like Johnny's sports comes to my view as Johnny's sports

How do I decode the string back to Johnny's Sports so I can query the database?

I've tried several urllib functions that have been suggested in other posts but I think I'm seriously misunderstanding how they work because I'm not seeing it work.

Any help is greatly appreciated.

2 Answers 2

2

Python's standardlib contains the HTMLParser. It can perform decoding of escaped HTML entities, as noted in this answer: https://stackoverflow.com/a/2087433/145400

>>> import HTMLParser
>>> h = HTMLParser.HTMLParser()
>>> print h.unescape('Johnny's sports')
Johnny's sports
Sign up to request clarification or add additional context in comments.

Comments

0

You might give the answer to this question a try. Seems to do what you need.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.