|decodeuricomponent vs decodeuri||1.06||0.8||3895||30|
decodeURIComponent () is a function property of the global object. decodeURIComponent () uses the same decoding algorithm as described in decodeURI (). It decodes all escape sequences, including those that are not created by encodeURIComponent, like -.!~*' (). decodeURIComponent () cannot be used directly to parse query parameters from a URL.What is the difference between encodeURI and encodeURIComponent?
Looks like encodeURI produces a "safe" URI by encoding spaces and some other (e.g. nonprintable) characters, whereas encodeURIComponent additionally encodes the colon and slash and plus characters, and is meant to be used in query strings. The encoding of + and ? and & is of particular importance here, as these are special chars in query strings.What is the difference between unescape and decodeuri?
Another vital difference is that unescape () does not handle multi-byte UTF-8 sequences whereas decodeURI [Component] () does: decodeURIComponent ("%C3%A9") == "é" unescape ("%C3%A9") == "Ã©" encodeURI — encodes characters that are not allowed (raw) in URLs (use it to fix up broken URIs if you can't fix them beforehand)What happens if decodeuri() fails to find the escape sequence?
So by reading the first escape sequence, decodeURI () can determine how many more escape sequences to consume. If decodeURI () fails to find the expected number of sequences, or if the escape sequences don't encode a valid UTF-8 character, a URIError is thrown.