Skip to content

Commit 329ccf0

Browse files
Merge pull request livecode#6446 from livecodesam/livecodesam-patch-1
[Bugfix 15614] Replace URLEncode example
2 parents 27de0d3 + cca5cf0 commit 329ccf0

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

docs/dictionary/function/URLEncode.lcdoc

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ Example:
2525
URLEncode("Test string $$") -- returns "Test+string+%24%24"
2626

2727
Example:
28-
put URLEncode("http://www.example.net/document.html") into newURL
28+
local tGoodURL
29+
put "http://www.example.net/" & URLEncode("A File Name with spaces.html") into tGoodURL
2930

3031
Parameters:
3132
formString (string):
@@ -45,7 +46,21 @@ Letters and numbers (alphanumeric characters) are not transformed by the
4546
characters is a percent sign followed by two <hexadecimal> digits. For
4647
example, the <ASCII|ASCII value> of the <character> ~ is 126; the
4748
hexadecimal equivalent of 126 is 7E. So wherever the <character> ~
48-
<a/>appears in the formString, it is converted to "%7E".
49+
appears in the formString, it is converted to "%7E".
50+
51+
>*Note:* The URLEncode function does not conform to RFC3986. In order
52+
> to produce a string that does conform to it, you would first encode
53+
> the string to UTF-8 and then after performing URLEncode, replace all
54+
> instances of "+" with "%20". For example:
55+
56+
function urlEncodeRFC pString
57+
if pString is strictly a string then
58+
put textEncode(pString,"UTF-8") into pString
59+
end if
60+
put URLEncode(pString) into pString
61+
replace "+" with "%20" in pString
62+
return pString
63+
end urlEncodeRFC
4964

5065
References: post (command), function (control structure),
5166
hexadecimal (glossary), encode (glossary), Escape key (glossary),

docs/notes/bugfix-15614.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fixed incorrect example in the dictionary entry for URLEncode.

0 commit comments

Comments
 (0)