Percent encoding javascript
Try encodeURIComponent() or escape()
encodeURI
, encodeURIComponent
or escape
will work the same way for your string, but they differ in details.
encodeURI
is just for escaping URLsencodeURIComponent
also escapes =
and &
escape
works differently with non-ASCII unicode symbols
encodeURI("Ω") === encodeURIComponent("Ω") === "%CE%A9"
escape("Ω") === "%u03A9"
if you need to send a string as part of request, use encodeURIComponent