[TOC] [Prev] [Next] [Bottom]



Encoding Attribute

Many value-returning meta tags accept an ENCODING attribute that determines how returned values are formatted. Each of the valid format types is described in this section.

If no encoding attribute is specified, values returned by meta tags used in Results HTML, No Results HTML, and Error HTML undergo a process of conversion so they appear correctly in the user's Web browser. For example, < is converted to &lt;.

NONE

The NONE value for the ENCODING attribute allows you to indicate that the value returned by the meta tag contains HTML formatting codes that are to be passed back to the user's Web browser without translation. The main use for this attribute is for displaying HTML stored in database fields and variables.

For example:

<@COLUMN NAME="pages.theHTMLpage" ENCODING="NONE">


!Note: This attribute value was called "HTML" in previous versions of Tango.


METAHTML

The METAHTML attribute value of the ENCODING attribute performs the same function as NONE but also looks for Tango meta tags in the value and evaluates any it finds.

For example:

<@COLUMN NAME="table.template" ENCODING="METAHTML">

If the template column contains the text <@VAR NAME="foo">, the example shown returns the current value of the variable foo.

MULTILINE

The MULTILINE attribute value causes Tango to replace return, line feed, and return/line feed combinations in the value with <BR> tags. Normally, Web browsers ignore line breaks in HTML. Use this attribute to force the display of returns in database values.

MULTILINEHTML

The MULTILINEHTML attribute value lets you combine the functions of NONE and MULTILINE. This formatting attribute is particularly useful for formatting data entered by users who have used HTML tags for character formatting (for example, bolding and italicization), but who have not used <BR> or <P> tags to properly indicate line or paragraph endings.

URL

The URL formatting attribute value tells Tango to make the value returned by a meta tag safe for inclusion in a URL by encoding special characters such as spaces and slashes, according to the scheme set out in RFC 1630. The main use for this attribute value is to construct URLs containing database or user-entered values.

For example:

<A HREF="/customer_detail?cust_name=
<@COLUMN NAME='customer.cust_name' ENCODING='URL'>">
More customer info</A>

If the URL attribute were not used in this case, links to customer names from the database that contained spaces would not work properly because a space is invalid in a URL. By using the URL attribute value, any spaces are converted to %20. Similarly, other special characters that have meaning in URLs (~, #, and so on) are also converted.

The <@URLENCODE> meta tag performs the same function on any value. It is strongly recommended that you get into the habit of encoding any meta tags included in a URL, even if you think the value returned is not going to require it.

JAVASCRIPT

Encodes the value to make it a valid JavaScript literal. It does this by escaping certain characters using a backslash; for example, tabs are converted to \t. Use this type of encoding when using a meta tag in server- or client-side JavaScript code.

SQL

The SQL encoding type converts the specified value by doubling all occurrences of the single quote character.

For more information, see "Direct DBMS SQL Auto-Encoding" in Chapter 18 of the User's Guide and "noSQLEncoding" .

Tango Server automatically performs SQL encoding on meta tag values substituted in Direct DBMS SQL, except when the configuration variable noSQLEncoding is set to true. The SQL ENCODING attribute value is generally appropriate only when noSQLEncoding is set to true, and allows you to toggle SQL encoding on or off for particular meta tags.

For example:

<@ASSIGN NAME=mySQL VALUE="SELECT * FROM customer WHERE cust_name=<@SQ>">

<@ASSIGN NAME=mySQL VALUE="<@ARG cust_name ENCODING=sql><@SQ>"



[TOC] [Prev] [Next] [Bottom]



docs@pervasive.com

Copyright © 1998, Pervasive Software Inc. All rights reserved.