JSFiddle - React, Tailwind, and code Playground
HTML
<span id="high-unicode">𝑥<!-- mathematical italic small x -->󳇠<!-- some char from Supplementary Private Use Area-A -->A<!-- char A -->􈅱<!-- some char from Supplementary Private Use Area-B --></span>
JavaScript
function decodeUnicode(str) {
var r = [], i = 0;
while(i < str.length) {
var chr = str.charCodeAt(i++);
if(chr >= 0xD800 && chr <= 0xDBFF) {
// surrogate pair
var low = str.charCodeAt(i++);
r.push(0x10000 + ((chr - 0xD800) << 10) | (low - 0xDC00));
} else {
// ordinary character
r.push(chr);
}
}
return r;
}
var txt = $('#high-unicode').text();
var codes = decodeUnicode(txt);
alert(codes);