The encodeurlquery( function encodes text so that it can be used in the query portion of a URL (the portion after the ? symbol).


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 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, as shown in this diagram.


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 included in the generated URL. Here’s an example that generates the URL for the address in the current database record and then opens Safari to this page.

let mapURL = "http://mymaps.com/displaymap?"+
openurl mapURL

Suppose the current record in the database contains this address:

 2024 Acadia Lane, Sàn Carlos, CA 98453

The generated URL will be:


Note that the spaces and accented characters have been converted to percent encoding.

If needed, you can convert this encoded text back into the original, unencoded text using the percentunescape( function.

See Also


10.2NewNew in this version.