Trying to port a snippet of code from Python:
my_input = "this&is£some text"
encoded_input = urllib.quote_plus(str(my_input))
...to JavaScript:
var my_input = "this&is£some text";
encoded_input = encodeURIComponent(my_input);
The minor difference is that urllib.quote_plus()
will convert spaces to +
instead of %20
(link).
Just wondering if anyone could provide any ideas.
Currently going with this...
var my_input = "this&is£some text";
encoded_input = encodeURIComponent(my_input).replace(/%20/g,'+');