// Encode a URI:
var uri = "http://w3schools.com/my test.asp?name=ståle&car=saab";
Print("Encoded URI: " & encodeURIComponent(uri));
EncodeURIComponent/decodeURIComponent: Difference between revisions
Jump to navigation
Jump to search
Created page with "encodeURIComponent(''URI'') decodeURIComponent(''URI'') == Description == The encodeURIComponent() function encodes a URI component. This function encodes special character..." |
No edit summary |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 9: | Line 9: | ||
The decodeURIComponent() function decodes a URI component. | The decodeURIComponent() function decodes a URI component. | ||
== Example | == Example == | ||
Encode a URI: | <tabber> | ||
< | JavaScript= | ||
uri = "http://w3schools.com/my test.asp?name= | <syntaxhighlight lang="JavaScript"> | ||
// Encode a URI: | |||
var uri = "http://w3schools.com/my test.asp?name=ståle&car=saab"; | |||
Print("Encoded URI: " & encodeURIComponent(uri)); | |||
</syntaxhighlight> | |||
|-| | |||
BASIC= | |||
<syntaxhighlight lang="vb.net"> | |||
' Encode a URI: | |||
uri = "http://w3schools.com/my test.asp?name=ståle&car=saab" | |||
Print "Encoded URI: " & encodeURIComponent(uri) | Print "Encoded URI: " & encodeURIComponent(uri) | ||
</ | </syntaxhighlight> | ||
The result | </tabber> | ||
The result will be: | |||
<pre> | <pre> | ||
Encoded URI: http%3A%2F%2Fw3schools.com%2Fmy%20test.asp%3Fname%3Dst%C3%A5le%26car%3Dsaab | Encoded URI: http%3A%2F%2Fw3schools.com%2Fmy%20test.asp%3Fname%3Dst%C3%A5le%26car%3Dsaab | ||
</pre> | </pre> | ||
== Related Items == | == Related Items == | ||
[[escape/unEscape|escape]], [[escape/unEscape|unescape]], [[ | [[escape/unEscape|escape]], [[escape/unEscape|unescape]], [[encodeURI/decodeURI|encodeURI]], [[encodeURI/decodeURI|decodeURI]] | ||
[[Category:Language Reference]] | [[Category:Language Reference]] | ||
[[Category:Variable Handling]] | [[Category:Variable Handling]] |
Latest revision as of 14:15, 24 July 2019
encodeURIComponent(URI)
decodeURIComponent(URI)
Description
The encodeURIComponent() function encodes a URI component. This function encodes special characters. In addition, it encodes the following characters: , / ? : @ & = + $ #
The decodeURIComponent() function decodes a URI component.
Example
' Encode a URI:
uri = "http://w3schools.com/my test.asp?name=ståle&car=saab"
Print "Encoded URI: " & encodeURIComponent(uri)
The result will be:
Encoded URI: http%3A%2F%2Fw3schools.com%2Fmy%20test.asp%3Fname%3Dst%C3%A5le%26car%3Dsaab