I've been looking the answers here in this web site, but nothing have worked so far. The problem is:
In the database, strings are saved like that one: at √s = 7 TeV with.
And the reason is that the "escape" JavaScript function was used.
I was not able to "unescape" these strings in Python yet. I tried to use "eval", "decode", "re.sub" and others, but without success. So please, which function can I use to get it right?
-
2Please specify in even more detail what you have, and what youl would expect. The quoted string you have no is hard to make sense of.unwind– unwind2011年02月28日 14:46:43 +00:00Commented Feb 28, 2011 at 14:46
-
3That string is not a product of the JavaScript "escape" function. If it were, there'd be no spaces in it, and the ampersand would be encoded too.Pointy– Pointy2011年02月28日 14:51:45 +00:00Commented Feb 28, 2011 at 14:51
-
look at here stackoverflow.com/questions/628332/…Yuda Prawira– Yuda Prawira2011年02月28日 14:56:48 +00:00Commented Feb 28, 2011 at 14:56
2 Answers 2
The string in question looks like it's encoded with HTML entities, in which case a routine like this one would be appropriate for unescaping. Here's how it looks for your string:
>>> print unescape('at √s = 7 TeV with')
at √s = 7 TeV with
Comments
urllib.unquote should undo most if not all of the Javascript escape() function, but specific details on what you're getting out of escape() might help verify this