Script Character Encoding
JavaScript engines support several familiar, backslash-based string-encoding methods that can be employed to escape quote characters, HTML markup, and other problematic bits in the embedded text. These methods are as follows:
C-style shorthand notation for certain control characters: \b for backspace, \t for horizontal tab, \v for vertical tab, \f for form feed, \r for CR, and \n for LF. This exact set of escape codes is recognized by both ECMAScript and the JSON RFC.
Three-digit, zero-padded, 8-bit octal character codes with no prefix (such as “\145” instead of “e”). This C-inspired syntax is not a part of ECMAScript but is in practice supported by all scripting engines, both in normal code and in JSON.parse(...).
Two-digit, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access