Skip to content

Instantly share code, notes, and snippets.

@SMotaal
Created October 10, 2017 17:12
Show Gist options
  • Save SMotaal/928b5e86662a277509315a8342a4fbd0 to your computer and use it in GitHub Desktop.
Save SMotaal/928b5e86662a277509315a8342a4fbd0 to your computer and use it in GitHub Desktop.
Surrogate Pairs Roundtrip
(
(
str,
c = `${str}`.codePointAt(0),
p = 0x10000, q = 0x400, r = 0xD800, s = 0xDC00,
h = ~~((c-p) / q) + r, l = (c - p) % q + s
) => ({
h, l,
c1: c, c2: (h - r) * q + l - s + p
})
)('\u{2CAE}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment