EncodeJava (open)

Escapes special characters for use in java strings.

Syntax

// Core function, no LOADLIB necessary

STRING FUNCTION EncodeJava(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. Encodejava returns string with these conversions made.

EncodeJava escapes " (double quote), ' (single quote) and \ (backslash) 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')");