liveBook · Manning

Surrogate pair

A surrogate pair is two UTF-16 code units that together represent one Unicode code point outside the Basic Multilingual Plane.

How 2 Manning books explain it

JavaScript in Depth

A two-code-unit sequence in UTF-16 used together to represent a code point outside the basic multilingual plane.

How it is used
Explains why one Unicode code point can require two 16-bit values in a JavaScript string.
How deep it goes
Works through decoding a concrete pair into a code point and identifies invalid UTF-16 as a possible string state.
Examples
Decodes U+10437 from 0xD801 and 0xDC37 and contrasts regular-expression matches with and without the `u` flag.
What you can do after
Diagnose/debug with it when JavaScript regular expressions split a supplementary code point into two matches.

Read how JavaScript in Depth explains surrogate pair →

100 Java Mistakes and How to Avoid Them

A surrogate pair is two UTF-16 code units that together encode one Unicode code point outside the Basic Multilingual Plane.

How it is used
Prevents string-processing code from treating UTF-16 code units as complete displayed characters.
How deep it goes
Explains surrogate encoding, split consequences, combining-character complications, and code-point-aware remedies.
Examples
Uses emoji splitting, skin-tone modifiers, substring chunking, code-point streams, and BreakIterator boundaries.
What you can do after
Diagnose and prevent Unicode corruption by replacing char-based boundaries with code-point or character-boundary processing.

Read how 100 Java Mistakes and How to Avoid Them explains surrogate pair →

Also covered in

Related concepts

Questions about surrogate pair

What is surrogate pair?

A surrogate pair is two UTF-16 code units that together represent one Unicode code point outside the Basic Multilingual Plane.

Which Manning books explain surrogate pair?

JavaScript in Depth and 100 Java Mistakes and How to Avoid Them.

What is the difference between surrogate pair and JavaScript?

A surrogate pair is two UTF-16 code units that together represent one Unicode code point outside the Basic Multilingual Plane. JavaScript is a high-level, dynamically typed programming language standardized as ECMAScript and used for web and general-purpose programming.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.