At first, the source file must be encoded UTF-8.
You have to put chcp 65001
for UTF-8 console encoding.
Explore the character hexcode. The full understanding of unicode character form is there: unicode I am using the \u{HEX} form, it is universal.
Then use hex and template for evaluate the character.
test #1
var chr={hex:"03A9"} //Ω
chr.dec=parseInt("0x"+chr.hex,16);
chr.htmlx=String.fromCharCode(38)+"#x"+chr.hex+";";
chr.htmld=String.fromCharCode(38)+"#"+chr.dec+";";
chr.unicode="`"+String.fromCharCode(92)+"u{"+chr.hex+"}`";
chr.grafema=eval(chr.unicode);
console.log(JSON.stringify(chr,0,1));
console.log("unicode", chr.unicode);
console.log("decimal",String.fromCharCode(chr.dec));
console.log("grafema", chr.grafema);
Result:
{
"hex": "03A9",
"dec": 937,
"htmlx": "Ω",
"htmld": "Ω",
"unicode": "`\\u{03A9}`",
"grafema": "Ω"
}
unicode `\u{03A9}`
decimal Ω
grafema Ω
The String.fromCharCode() works.
test #2
var chr={hex:"1F353"} //🍓
chr.dec=parseInt("0x"+chr.hex,16);
chr.htmlx=String.fromCharCode(38)+"#x"+chr.hex+";";
chr.htmld=String.fromCharCode(38)+"#"+chr.dec+";";
chr.unicode="`"+String.fromCharCode(92)+"u{"+chr.hex+"}`";
chr.grafema=eval(chr.unicode);
console.log(JSON.stringify(chr,0,1));
console.log("unicode", chr.unicode);
console.log("decimal",String.fromCharCode(chr.dec));
console.log("grafema", chr.grafema);
{
"hex": "1F353",
"dec": 127827,
"htmlx": "🍓",
"htmld": "🍓",
"unicode": "`\\u{1F353}`",
"grafema": "🍓"
}
unicode `\u{1F353}`
decimal
grafema 🍓
The String.fromCharCode() does not works, due to greater than 0xFFFF has truncated.