encodeurlquery(
TEXT
)

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


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

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 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?"+
    "Street="+encodeurlquery(Address)+
    "&City="+encodeurlquery(City)+
    "&Zip="+encodeurlquery(Zip)
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:

http://mymaps.com/displaymap?Street=2024%20Acadia%20Lane&Address-S%C3%A0n%20Carlos&State=CA&Zip=98453

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


History

VersionStatusNotes
10.2NewNew in this version.