$Ent: Difference between revisions
(Automatically generated page update) |
(Automatically generated page update) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
<span class="pageSubtitle">Do character entity substitution</span> | <span class="pageSubtitle">Do character entity substitution</span> | ||
<p class="warn"><b>Note: </b> | <p class="warn"><b>Note: </b>Many $functions have been deprecated in favor of Object Oriented methods. There is no OO equivalent for the $Ent function.</p> | ||
This function performs character entity substitution on an input string using the default character entity substitution table or one set by the most recent <var>[[$Ent_Tab]]</var> call. | This function performs character entity substitution on an input string using the default character entity substitution table or one set by the most recent <var>[[$Ent_Tab]]</var> call. | ||
Line 9: | Line 9: | ||
The first argument is the string on which character entity translation is to be performed. This is an optional argument though the use of <var>$Ent</var> without this argument is somewhat silly as it simply returns a null. | The first argument is the string on which character entity translation is to be performed. This is an optional argument though the use of <var>$Ent</var> without this argument is somewhat silly as it simply returns a null. | ||
==Syntax== | ==Syntax== | ||
<p class="syntax"><span class="term">%result</span> = <span class="literal">$Ent</span>(<span class="term">string</span>) | <p class="syntax"><span class="term">%result</span> = <span class="literal">$Ent</span>(<span class="term">string</span>) | ||
</p> | </p> | ||
<p><var class="term">%result</var> is set to the value of | <p> | ||
Character entity substitution replaces characters that have special meaning to an HTML or XML processor with their character entity representation. For example, the | <var class="term">%result</var> is set to the value of <var class="term">string</var> with character entity substitution performed.</p> | ||
Character entity substitution replaces characters that have special meaning to an HTML or XML processor with their character entity representation. For example, the <code><</code> is represented as the <code>&lt;</code> character entity. A default character entity substitution table is provided that does the basic required character entity mappings for HTML and XML of <code>&</code> to <code>&</code>, <code><</code> to <code>&lt;</code> and the double quote character <code>"</code> to <code>&quot;</code>. The active character entity substitution table can be modified with <var>[[$Ent_Tab]]</var>. | |||
The following code | The following code prints <code>This is &lt; &quot;fun&quot;</code> if the default character entity substitution tables are in effect: | ||
<p class="code">PRINT $Ent('This is < "fun"') | <p class="code">PRINT $Ent('This is < "fun"') | ||
</p> | </p> | ||
Since character entity substitution always produces a string greater than or equal to the length of the input string, it is quite possible that a <var>$Ent</var> call will produce a string that is truncated at 255 bytes. If this is a concern, and the <var>$Ent</var> call is in a <var>Print</var> statement or is assigned to a variable that is ultimately printed, it is almost certainly better to have the character entity substitution occur at either of the following places, because in these cases the result of the character entity translation is not truncated at 255 bytes: | |||
Since character entity substitution always produces a string greater than or equal to the length of the input string, it is quite possible that a <var>$Ent</var> call will produce a string that is truncated at 255 bytes. If this is a concern, and the <var>$Ent</var> call is in a | |||
<ul> | <ul> | ||
<li>The <var>Print</var> statement, as a result of the <var>[[$Ent_Print]]</var> setting | |||
<li>The | <li>The <var>Html/Text</var> statement, as a result of <var>Ent_Print</var>, <var>Ent_Print</var>, or the <code>&</code> special character after an expression start string | ||
< | |||
</ul> | </ul> | ||
If this is not possible and truncation is a concern, another option is to break the string undergoing character entity substitution into pieces that are small enough that the resultant string cannot possibly be longer than 255 bytes. For the default substitution table, this would mean pieces no larger than 255/6 or 42 bytes, since the longest substitution string is | If this is not possible and truncation is a concern, another option is to break the string undergoing character entity substitution into pieces that are small enough that the resultant string cannot possibly be longer than 255 bytes. For the default substitution table, this would mean pieces no larger than 255/6 or 42 bytes, since the longest substitution string is <code>&quot;</code> which is 6 bytes long. | ||
==Products authorizing {{PAGENAMEE}}== | ==Products authorizing {{PAGENAMEE}}== | ||
Line 38: | Line 39: | ||
<li>[[Janus Web Server]]</li> | <li>[[Janus Web Server]]</li> | ||
<li>Japanese functions</li> | <li>Japanese functions</li> | ||
<li>[[Media:SirfieldNew.pdf|Sir2000 Field Migration Facility]</li> | <li>[[Media:SirfieldNew.pdf|Sir2000 Field Migration Facility]]</li> | ||
</ul> | </ul> |
Latest revision as of 22:51, 20 September 2018
Do character entity substitution
Note: Many $functions have been deprecated in favor of Object Oriented methods. There is no OO equivalent for the $Ent function.
This function performs character entity substitution on an input string using the default character entity substitution table or one set by the most recent $Ent_Tab call.
$Ent accepts one argument and returns a string result.
The first argument is the string on which character entity translation is to be performed. This is an optional argument though the use of $Ent without this argument is somewhat silly as it simply returns a null.
Syntax
%result = $Ent(string)
%result is set to the value of string with character entity substitution performed.
Character entity substitution replaces characters that have special meaning to an HTML or XML processor with their character entity representation. For example, the <
is represented as the <
character entity. A default character entity substitution table is provided that does the basic required character entity mappings for HTML and XML of &
to &
, <
to <
and the double quote character "
to "
. The active character entity substitution table can be modified with $Ent_Tab.
The following code prints This is < "fun"
if the default character entity substitution tables are in effect:
PRINT $Ent('This is < "fun"')
Since character entity substitution always produces a string greater than or equal to the length of the input string, it is quite possible that a $Ent call will produce a string that is truncated at 255 bytes. If this is a concern, and the $Ent call is in a Print statement or is assigned to a variable that is ultimately printed, it is almost certainly better to have the character entity substitution occur at either of the following places, because in these cases the result of the character entity translation is not truncated at 255 bytes:
- The Print statement, as a result of the $Ent_Print setting
- The Html/Text statement, as a result of Ent_Print, Ent_Print, or the
&
special character after an expression start string
If this is not possible and truncation is a concern, another option is to break the string undergoing character entity substitution into pieces that are small enough that the resultant string cannot possibly be longer than 255 bytes. For the default substitution table, this would mean pieces no larger than 255/6 or 42 bytes, since the longest substitution string is "
which is 6 bytes long.
Products authorizing $Ent
- Sirius functions
- Fast/Unload User Language Interface
- Janus Open Client
- Janus Open Server
- Janus Sockets
- Janus Web Server
- Japanese functions
- Sir2000 Field Migration Facility