Created
October 10, 2017 17:12
-
-
Save SMotaal/928b5e86662a277509315a8342a4fbd0 to your computer and use it in GitHub Desktop.
Surrogate Pairs Roundtrip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
( | |
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