The encodeurluser( function encodes text so that it can be used in the user name portion of a URL.
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):
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
History
Version | Status | Notes |
10.2 | New | New in this version. |