EncodeHareScript (open)
Escapes special characters for use in HareScript strings.
Syntax
// Core function, no LOADLIB necessary
STRING FUNCTION EncodeHareScript(STRING text)
Parameters
STRING text
String to encode
Return value
STRING
The encoded string
Description
Certain characters have special significance in strings, and should be escaped to preserve their meaning. EncodeHareScript returns string with these conversions made.
EncodeHareScript escapes " (double quote), ' (single quote), \ (backslash) characters, control characters, unicode characters and invalid UTF-8 encoded characters.
Examples
// returns "alert(\'Johnny and Jane\')"
STRING example1 := EncodeJava("alert('Johnny and Jane')");
// returns "alert(\'A\\n\\b\')"
STRING example2 := EncodeJava("alert('A\n\b')");