encodeurlhost(
TEXT
)
The encodeurlhost( function encodes text so that it can be used in the host portion of a URL (for example www.host.com).
Parameters
This function has one parameter:
text – text to be encoded.
Description
When you are constructing a URL from data, many characters must be encoded using percent encoding (see RFC 3986 – Uniform Resource Identifier (URI): Generic Syntax. Different components of the URL require different characters to be encoded, for example, the query component of a URL allows the “@” character, but that character must be percent encoded when used in the password component. There are six different possible URL components: user, password, host, path, query and fragment.
http://user:password@host/path?query#fragment
Panorama has six separate functions for properly encoding each of these components (these functions replace the now obsolete *urlencode(* function):
- encodeurluser( encodes text that will be placed in the user component.
- encodeurlpassword( encodes text that will be placed in the password component.
- encodeurlhost( encodes text that will be placed in the host component.
- encodeurlpath( encodes text that will be placed in the path component.
- encodeurlquery( encodes text that will be placed in the query component.
- encodeurlfragment( encodes text that will be placed in the fragment component (after a # character).
The most commonly used of these functions is encodeurlquery(. For example, suppose you have a database that has Address, City and State fields, and you want to pass that data to a website that displays maps based on parameters in the URL. The urlencodequery( function will ensure that the Unicode data in the database is correctly encoded to be passed in the generated URL.
"http://mymaps.com/displaymap?"+
"Street="+encodeurlquery(Address)+
"&City="+encodeurlquery(City)+
"&Zip="+encodeurlquery(Zip)
For example, suppose the database contains this address:
2024 Acadia Lane, Sàn Carlos, CA 98453
The generated URL will be:
http://mymaps.com/displaymap?Street=2024%20Acadia%20Lane&Address-S%C3%A0n%20Carlos&State=CA&Zip=98453
If needed, you can convert this encoded text back into the original, unencoded text using the percentunescape( function.
See Also
- cgilink( -- creates a domain independent URL for another CGI action on the same server.
- cgilinknewwindow( -- creates a domain independent link for another CGI action on the same server that opens a new browser window.
- cginavlink( -- creates a domain-independent navigation link for the current record in this database.
- cginavlinknewwindow( -- creates a domain-independent navigation link (to a new browser window) for the current record in this database.
- encodeurlfragment( -- encodes text so that it can be used in the fragment portion of a URL (the portion after the # symbol).
- encodeurlpassword( -- encodes text so that it can be used in the password portion of a URL.
- encodeurlpath( -- encodes text so that it can be used in the path portion of a URL (the portion after the host name, but before any ? symbol).
- encodeurlquery( -- encodes text so that it can be used in the query portion of a URL (the portion after the ? symbol).
- encodeurluser( -- encodes text so that it can be used in the user name portion of a URL.
- htmldecode( -- converts HTML text into regular text by converting any special HTML entities (`&`, `©`, etc.) into the corresponding characters.
- htmlencode( -- converts standard text into HTML text by converting any special characters into the equivalent HTML entities.
- urldecode( -- decodes text that contains percent encoded characters.
- urlencode( -- converts text into a legal URL (by converting spaces into `%20`). WARNING: THIS FUNCTION IS OBSOLETE.
- webformlink( -- generates a link to a Panorama form on the current web site (the link will open in a new browser window).
- webformlinknewwindow( -- generates a link to a Panorama form on the current web site.
- weblink( -- builds an HTML link tag
- weblinknewwindow( -- builds an HTML link tag
History
10.2 | New | New in this version. |