Help Search Campus Map Directories Webmail Home Alumnae Academics Admission Athletics Student Life Offices & Services Library & Technology News & Events About the College Navigation Bar
MHC Home Using the Document Interface
TopNext Page

Special Characters in Strings

In order to prevent the Document Interface from interpreting certain characters contained in strings as special sequences, it is necessary to "escape" them by preceding them with a \.

For instance, if you have the string "$foo", you are invoking a reference to the variable foo. If you actually wanted to display a $, though, you would have to use "\$foo". The \ means "don't give any special meaning to the $." Actually, another way around this is to use '$foo', which will also prevent foo from being interpreted as the name of a variable. You will probably find that there are cases where one method or the other is easier to use.

To include a quote within a set of the same quotes, you should escape it as well. Another case that must be preceded by \ is the @ character, when used as part of an .IF, .ELSIF, .SET, or .ECHO command. Actually, you can precede any non-alphanumeric character with a \ if you really want to be careful:

<!--.echo "He said, \"Hey, dude!\""--> (Need slashes with embedded quotes)
<!--.echo 'He said, "Hey, dude!"'-->   (No slashes needed, since outer quotes are different)
<!--.echo "dwilga@mtholyoke.edu"-->    (Produces a syntax error message)
<!--.echo "dwilga\@mtholyoke.edu"-->   (Correct)
<!--.echo "dwilga\@mtholyoke\.edu"-->  (Correct too!)
<!--.echo 'dwilga@mtholyoke.edu'-->    (Also works, but can't include variables)


More Special Sequences

These expressions can also be used in strings:

Sequence

Result

\\ Two \'s next to each other become a single \.
\n Newline. Not very useful since newlines are ignored in HTML. You probably want <P> or <BR> instead.
\NNN ASCII character in octal. For example \101 for "A".
\xNN ASCII character in hexadecimal. For example, \x41 for "A".
\L ... \E Lowercase the rest of the string, or until \E. For example, "a\LbCDeF" produces "abcdef". Useful in string comparisons.
\U ... \E Uppercase the rest of the string, or until \E. For example, "a\UbCDeF" produces "aBCDEF". Useful in string comparisons.
\l Lowercase the next letter of the string. For example, "a\lBCDeF" produces "abCDeF".
\u Uppercase the next letter of the string. For example, "a\ubcdef" produces "aBcdef".
\S ... \E Omit any extra spaces in the rest of the string, or until \E. Does not alter text within HTML tags. For example, "\S <h3 align=center> TITLE </h3>" produces "<h3 align=center>TITLE</h3>". Useful because some browsers display certain tags differently if there are spaces before or after them.

----------------------------------------
Top | Next Page

Home | Directories | Web Email | Calendar | Campus Map | Search | Help

About the College | Admission | Academics | Student Life | Athletics
Offices & Services | Giving | News & Events | Alumnae | Library & Technology

Copyright © 2002 Mount Holyoke College. This page created by the OIS Operations Group and maintained by Webmaster. Last modified on February 11, 2002.