I'm dealing with raw strings containing escape sequences for surrogate halves of UTF astral symbols. (I think I got that lingo right…)
console.log("\uD83D\uDCA9")
// =>
Let's use the above emoji as an example. If I have the surrogate pair (\uD83D\uDCA9) How can I in turn take it's hexadecimal values and turn it into a valid argument for Javascript's String.fromCodePoint()
function?
I've tried the following:
const codePoint = ["D83D", "DCA9"].reduce((acc, cur) => {
return acc += parseInt(cur, 16);
}, 0);
console.log(String.fromCodePoint(codePoint));
// => (some weird symbol appears, not !)
PS: I'm familiar with ES6 escape sequences which show hexadecimal values between brackets {…} instead of using surrogate halves. But I need to do this with surrogate pairs!
Any suggestions are greatly appreciated.