Is there a javascript function that takes a string and converts it into another string that is percent-encoded? That way something like "This Guy" turns into "This%20Guy".
Thanks
The encodeURI() function encodes a URI by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two "surrogate" characters).
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
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