PreviousNext

Including Special Characters with Backslashes

We already know that dcecp relies on certain special characters such as spaces, braces, quotes, or dollar signs to control its interpretation of elements. Sometimes, you might want to include one special character in a string, temporarily suspending its special interpretation. The backslash (\) character provides a form of substitution that suppresses special interpretation of the character immediately following the backslash.

Use the backslash character (\) to insert a non-printing space character in a string of elements. For instance, each of the following dcecp lists have three elements:

a b\ c d
a b \{

The elements in the first example are a, b c, and d. The elements in the second example are a, b, and {. A more practical example could use the backslash to include quotes in error messages as shown in the following code fragment:

if {[llength $a] < 2} {
error "Unable to parse \"$element_list\"."
}

The following list shows the special characters that you can include in a string of elements using the backslash character.

\b Backspace
\t Tab
\e Escape
\n Newline
\r Carriage-return
\{ Left brace
\} Right brace
\[ Open bracket
\] Close bracket
\$ Dollar sign
\ (space) Space " "
\; Semi-colon
\" Double quote
\\ Backslash
\newline Nothing
\ddd Octal value