Escape |
|
Description
Escapes special characters in strings so that the results of constant and macro expressions can be embedded in code snippets for the target language/usage.
Arguments
1.Escape - Name of the Macro.
2.Target - platform where the string escape is targeted. Valid values are XML, XMLAttribute, HTML, HTMLAttribute, C#, and both the ' (Single Quote), and " (Double Quote) characters.
3.Expression - A macro expression that will be escaped.
Examples
Note that in some of the examples the characters in the strings are also macro expression separator characters and are themselves escaped with a % character (further demonstrating why this is necessary).
<Escape|C#|This string contains a backslash \ and a double quote " character.>
Returns "This string contains a backslash \\ and a double quote \" character."
<Escape|'|Escaping characters is "fun", isn't it?>
Returns "Escaping characters is "fun", isn''t it?"
<Escape|"|Escaping characters is "fun", isn't it?>
Returns "Escaping characters is ""fun"", isn't it?"
<Escape|HTML|This is an %<HTML%> string with an ampersand & in it.>
Returns "This is an <HTML> string with an ampersand & in it.".
<Escape|HTML|'This' is an %<HTML%> string with An entity reference>
Returns "'This' is an <HTML> string with aAn entity reference".
<Escape|HTMLAttribute|This is an %<HTML%> string>
Returns "This is an <HTML> string".
<Escape|XML|This is an %<XML%> string with an ampersand & in it.>
Returns "This is an <XML> string with an ampersand & in it".
<Escape|XML|'This' is an %<XML%> string with An entity reference>
Returns "'This' is an <XML> string with An entity reference".
<Escape|XMLAttribute|This is an %<XML%> string>
Returns "This is an <XML> string".
Notes
This macro command handles the following target language operations:
•': Replaces each single quote with two single quote characters. Ideal for use with SQL Server character types and PowerShell literal strings.
•": Replaces each double quote with two double quote characters. Ideal for use with PowerShell expansion strings and Visual Basic language.
•C#: Escapes backslash characters and double quote characters. Ideal for use in Managed Code or Managed Assembly job steps targeting the C# language.
•HTML: Escapes the ampersand (&), single and double quotes (' and "), and both angle brackets (< and >) and character entity references with HTML specific coding. Ideal for HTML raw element content.
•HTMLAttribute: Escapes the ampersand (&), double quote ("), and left angle bracket (<) with HTML specific coding. Ideal for HTML attributes.
•XML: Escapes the ampersand (&), single and double quotes (' and "), and both angle brackets (< and >) with XML specific coding. Ideal for XML raw element content.
•XMLAttribute: Escapes the ampersand (&), double quote ("), and left angle bracket (<) with XML specific coding. Ideal for XML attributes.
Copyright © 2024 pasUNITY, Inc.
Send comments on this topic.
Created with an evaluation copy of HelpSmith.
To remove this notice, you should purchase the full version of the product.