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,'+');
Use urllib.quote()
instead of quote_plus()
in your Python code. If changing the Python code is not a solution, your choice of replacing %20
with +
is the preferred method anyway (reference, second paragraph in Description).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With