Character display semantics (Definition)

How characters are displayed on the implementation's console.

Although the standard defines many escape sequences (see table), how these are displayed depends very much on the way that the implementation uses the output of JavaScript:

Escape SequenceNameSymbol
\"Double Quote"
\'Single Quote (Apostrophe)'
\aAudible alert (MSIE displays the letter a)<BEL>
\bBackspace (ignored silently in MSIE)<BS>
\fForm Feed (ignored silently in MSIE)<FF>
\nLine Feed (Newline - MSIE inserts a space)<LF>
\rCarriage Return (MSIE inserts a space)<CR>
\tHorizontal Tab (MSIE inserts a space)<HT>
\vVertical tab (MSIE displays the letter v)<VT>
\0nnOctal escape-
\042Double Quote"
\047Single Quote (Apostrophe)'
\xnnHexadecimal escape-
\x22Double Quote"
\x27Single Quote (Apostrophe)'
\unnnnUnicode escape-
\u0022Double Quote"
\u0027Single Quote (Apostrophe)'
\uFFFEA special Unicode sentinel character for flagging byte-reversed text-
\uFFFFA special Unicode sentinel character-

Encoding line feeds, form feeds, and tabs into data that ultimately gets output as part of a document.write() method suggests that the target is an HTML page. When HTML is rendered, any embedded tabs and line terminators have no effect at all on the displayed output apart from some undesirable side effects in older browsers, which used to display line terminators inside anchor tags in a very odd way.

On the other hand, JavaScript that is generating a text data stream that is going to be returned via a TCP socket may well want to encode all kinds of escaped control characters.


See also:Character set, Environment, Escape sequence (\)