The encodeurlhost( function encodes text so that it can be used in the host portion of a URL (for example www.host.com).
This function has one parameter:
text – text to be encoded.
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 have 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.
Panorama has six separate functions for properly encoding each of these components (these functions replace the now obsolete urlencode( function):
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:
If needed, you can convert this encoded text back into the original, unencoded text using the percentunescape( function.
|10.2||New||New in this version.|