Escape Sequences

An escape sequence tells the compiler to use an alternative interpretation of the character(s) following the escape character. In JS++, the escape character is the backslash (\). When the compiler encounters a backslash inside a string or character literal, it knows the characters following the backslash are "special."

In order to use single quotes inside a string wrapped by single quotes, we need to "escape" the single quote character used inside the string. Likewise, in order to use double quotes inside a string wrapped by double quotes, we need to "escape" the double quote character used inside the string. The escape sequence for a single quote is a backslash followed by a single quote character (\'), and the escape sequence for double quotes is a backslash followed by a double quote character (\").

Escape Sequence Description
\'Single quote
\"Double quote
\`Grave accent
\\Backslash
\/Forward slash
\nNew line
\rCarriage return
\tTab
\bBackspace
\fForm Feed
\vVertical Tab
\0Null character
\xNNLatin-1 character (replace NN)
\uNNNNUnicode codepoint (replace NNNN)

See Also

Share

HTML | BBCode | Direct Link