I'm attempting to update the icons used in an application that has a nested webview within it. I'm currently able to load specific icons with our icon font using specific hex codes like this: "\u{F053D}". The problem I'm running into is now that I'm trying to get dynamic icons defined from elsewhere in the application, I can't find a valid syntax to instert a variable into the place of the static hex code I was testing with.
Here are a few things I tried with hexCode representing a variable containing a string value like "F053D":
'\u{hexCode}' '\u{${hexCode}}' '\u{' + hexCode + '}'
But these say that a Hexadecimal didgit is expected after \u. Is there a way to insert a hex code here dynamically that I'm missing?
All you need to do is use String.fromCodePoint
to convert the hex sequence into a unicode string:
let hexCode = '1F600'
console.log(`Hello ${String.fromCodePoint(parseInt(hexCode, 16))} World`)