Difference between revisions of "DecodeURLComponent"

From Xojo Documentation

(Examples)
 
 
(14 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 +
{{MethodBox
 +
| name=DecodeURLComponent
 +
| platform=all
 +
| scope=global
 +
}}
 +
{{Description
 +
|text = Decodes the components of a URL that were encoded by [[EncodeURLComponent]] or equivalent. }}
  
 +
== Usage ==
 +
''result'' = '''DecodeURLComponent'''(''str'' [,''enc''])
 +
{| class="genericTable"
  
=='''Description'''==
+
! width=15% | Part
Decodes the components of a URL that were encoded by [[EncodeURLComponent|EncodeURLComponent]] or equivalent.
 
  
 +
! width=15% | Type
  
 
+
! width=55% | Description
=='''Syntax'''==
 
'''result'''=DecodeURLComponent('''str [,enc]''')
 
{| cellpadding="8" cellspacing="0" border="1"
 
 
 
! width=25%  style="background-color:#e0e0e0" | Part
 
 
 
! width=15%  style="background-color:#e0e0e0" | Type
 
 
 
! width=55% style="background-color:#e0e0e0" | Description
 
 
|-
 
|-
 
|result
 
|result
  
|[[String|String]]
+
|[[String]]
 
|The 'original' string.
 
|The 'original' string.
  
Line 24: Line 25:
 
|str
 
|str
  
|[[String|String]]
+
|[[String]]
 
|The encoded URL.
 
|The encoded URL.
  
Line 30: Line 31:
 
|enc
 
|enc
  
|[[TextEncoding|TextEncoding]]
+
|[[TextEncoding]]
|The [[TextEncoding|TextEncoding]] to be used to decode ''str''.
+
|The [[TextEncoding]] to be used to decode ''str''.
  
 
|-
 
|-
 
|}
 
|}
  
 +
== Notes ==
 +
A valid URL consists of alphanumerics, special characters and some reserved characters. Use DecodeURLComponent to convert encoded characters back to their original values.
  
=='''Notes'''==
+
The optional text encoding parameter is used to specify the original encoding of the string. To specify the encoding, use the [[Encodings]] module as shown in the second example.
A valid URL is a series of components that are separated by component separators. They are the ".", "/", ";", "&", and "?". [[EncodeURLComponent|EncodeURLComponent]] works with each component part of the URL. It assumes that any component separators in a component represent text and must be encoded. An encoded URL is decoded by '''DecodeURLComponent'''.
 
 
 
The optional text encoding parameter is used to specify the original encoding of the string. To specify the encoding, use the [[Encodings|Encodings]] module as shown in the second example.
 
 
 
 
 
  
=='''Examples'''==
+
== Sample Code ==
Here is an example of how an encoded URL is decoded.
+
Here are examples of how an encoded URL is decoded.
  
<div style="background-color:#d0d0d0; padding-left:30px">[[Dim|Dim]] s as [[String|String]]<br /></div>
+
<rbcode>
<div style="background-color:#d0d0d0; padding-left:30px">s='''DecodeURLComponent'''("www.bob%26ray.com")   //returns "www.bob&ray.com"<br /></div>
+
Var s As String
<div style="width:100%; background-color:#d0d0d0; padding-left:30px">s='''DecodeURLComponent'''([[TextField|TextField1]].Text,[[Encodings|Encodings]].DOSArabic))<br /></div>
+
s = DecodeURLComponent("www.bob%26ray.com") // returns "www.bob&ray.com"
 +
s = DecodeURLComponent(TextField1.Value, Encodings.DOSArabic))
 +
</rbcode>
  
=='''See Also'''==
+
== See Also ==
[[Encodings|Encodings]] module, [[EncodeURLComponent|EncodeURLComponent]] function.
+
[[Encodings]] module, [[EncodeURLComponent]] function.
  
  
[[Category:Internet]]
+
[[Category:Internet/Networking_Internet]]

Latest revision as of 22:23, 17 July 2019

Method

Decodes the components of a URL that were encoded by EncodeURLComponent or equivalent.

Usage

result = DecodeURLComponent(str [,enc])

Part Type Description
result String The 'original' string.
str String The encoded URL.
enc TextEncoding The TextEncoding to be used to decode str.

Notes

A valid URL consists of alphanumerics, special characters and some reserved characters. Use DecodeURLComponent to convert encoded characters back to their original values.

The optional text encoding parameter is used to specify the original encoding of the string. To specify the encoding, use the Encodings module as shown in the second example.

Sample Code

Here are examples of how an encoded URL is decoded.

Var s As String
s = DecodeURLComponent("www.bob%26ray.com") // returns "www.bob&ray.com"
s = DecodeURLComponent(TextField1.Value, Encodings.DOSArabic))

See Also

Encodings module, EncodeURLComponent function.