10.1.1 String literals

A string literal is a sequence of characters inside a pair of double quotes or single quotes:

var a = "foo";
var b = 'foo';
trace(a == b); // true

The only difference between the two forms is that single-quoted literals allow string interpolation.

String literals may occupy multiple lines; In which case, each line of the string will be punctuated with a '\n' newline character (See the escape sequences chart below).

var str = "Line one
Line two
Line three";
trace(str);

Note that indentation will also be included in the string, such as with the example below.

class X {
  function foo() {
    var str = "a
    b
    c";
  }
}

The str variable will have four spaces before 'b' and 'c'.

Escape sequences
SequenceMeaningUnicode codepoint (decimal)Unicode codepoint (hexadecimal)
\thorizontal tab (TAB)90x09
\nnew line (LF)100x0A
\rnew line (CR)130x0D
\"double quote340x22
\'single quote390x27
\\backslash920x5C
\NNNASCII escape where NNN is 3 octal digits0 - 1270x00 - 0x7F
\xNNASCII escape where NN is a pair of hexadecimal digits0 - 1270x00 - 0x7F
\uNNNNUnicode escape where NNNN is 4 hexadecimal digits0 - 655350x0000 - 0xFFFF
\u{N...}Unicode escape where N... is 1-6 hexadecimal digits0 - 11141110x000000 - 0x10FFFF