Table of Contents

stresc

Description

Process escape sequences in a string.

Function prototype

string stresc <string:Text>

Arguments

Name Type Comment
Text string The text string to be escaped.

Return value

A string containing the escaped text.

Example

string s
set s "The newlines has been escaped\\r\\n...and so have the \\\"quotation marks\\\""

// echo the escaped text
echo "Escaped:"
echo <stresc s>

// echo the unescaped text
echo "Unescaped:"
echo s

The escape sequences above needed to be double-escaped (i.e. '\\n') because the script interpreter processes escape sequences in literal strings once.

… the output of which is written to the event log by echo as:

Escaped:

The newlines has been escaped
...and so have the "quotation marks"

Unescaped:

The newlines has been escaped\r\n...and so have the \"quotation marks\"

Comments

Recognised escape sequences

Sequence Interpreted as…
\n Newline
\r Carriage return
\t Tab
\” Quotation mark
\\ Backslash
\0 NULL

See also