UrlEncode ( text )
Rate this function: Average rating: 3.2 (29 votes) Discuss this Custom Function
Jeremiah Small, Soliant Consulting
http://jsmall.us
Converts illegal and reserved URL characters into URL-legal hex code.
Sample Input:
| "http://www.database.com/page.php?field=" & UrlEncode ( "¶ \"!#$%&'()*+,-./:;<=>?@[\\]^`{|}" ) |
|
Sample Output:
| http://www.database.com/page.php?field=%0D%20%22%21%23%24%25%26%27%28%29%2A%2B%2C%2D%2E%2F%3A%3B%3C%3D%3E%3F%40%5B%5C%5D%5E%60%7B%7C%7D |
|
Description:
A complete table of hexadecimal codes can be found here http://www.december.com/html/spec/ascii.html
Be aware that curly quotes (single and double) are high-ascii, and will not be converted with this function. If you need quotes, make sure your input is with straight quotes.
Note: these functions are not guaranteed
or supported by BrianDunning.com. Please contact the individual
developer with any questions or problems.
This is my Custom Function and I want to
edit it
Discuss:Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:
|
Newest Custom Functions:
| 1. |
phpArrayValue ( array ; key ; pos ) |
| |
(Fri, Jan 27, 1:49pm) |
| 2. |
solfm_timeToMinutes (theTime;roundSec) |
| |
(Fri, Jan 20, 6:26am) |
| 3. |
filterLines(filterField;filterValue;Result) |
| |
(Sat, Jan 14, 2:20pm) |
| 4. |
getMaxValue ( theList ) |
| |
(Thu, Jan 12, 1:06pm) |
| 5. |
MiddleWordsIncPunct ( text ; startingWord ; numberOfWords ) |
| |
(Sat, Jan 07, 9:16am) |
| 6. |
WindowInfo |
| |
(Fri, Jan 06, 12:39pm) |
| 7. |
CenterWindow in Window vert horiz (demension) |
| |
(Fri, Jan 06, 12:25pm) |
| 8. |
UTF8_to_TXT ( Text , Platform ) |
| |
(Wed, Dec 28, 10:44pm) |
 |
|
The following version adds in a few more important substitutions...
/* See http://www.faqs.org/rfcs/rfc2368.html for mailto specifications
The following substitutions and their order are important. mailto: will fail without them.
Reserved characterss in a mailto: URL are "-", "&", and "?"
Must escape the % first, before you start adding them in.
Then do spaces and returns.
Stupify quotes and other stuff
Non-breaking space
Does not handle double quotes or tabs (%09)
Could add substitutions for all diacriticals and other less common characters */
Substitute (text;
["%"; "%25"];
[ " "; "%20"];
["¶"; "%0D"];
[ "!" ; "%21" ] ;
[ "$" ; "%24" ] ;
[ "(" ; "%28" ] ;
[ ")" ; "%29" ] ;
[ "*" ; "%2A" ] ;
[ "+" ; "%2B" ] ;
[ "." ; "%2E" ] ;
[ "=" ; "%3D" ] ;
["\“"; "%22"];
[ "\”"; "%22"];
["‘"; "%27"];
["’"; "%27"];
["'"; "%27"];
["…"; "..."];
["•"; "*"];
[ "-"; "%2D"];
["&"; "%26"];
["="; "%3D"];
["?"; "%3F"];
["#"; "%23"];
[","; "%2C"];
[ "/"; "%2F"];
[":"; "%3A"];
[";"; "%3B"];
[ "<"; "%3C"];
[ ">"; "%3E"];
["@"; "%40&quo
Tim Cimbura, Minneapolis, MN
May 01, 2010 7:59pm