I was reviewing a code where they author did something like this
const emojis: Array<Icon | undefined> | undefined = emojiSet
.map((emoji) => {
if (emoji.name && emoji.unified) {
const codePoints = emoji.unified
.split("-")
.map((token) => Number("0x" + token));
return {
name: emoji.name,
value: String.fromCodePoint(...codePoints),
index: emoji.unified,
};
}
return undefined;
})
.filter(Boolean);
To understand the code, I went through this repo (which is what the above is using to iterate over the json)
Here, in the example unified is "unified": "261D-FE0F",
When he does this,
const codePoints = emoji.unified
.split("-")
.map((token) => Number("0x" + token));
He is iterating over 261D-FE0F
and mapping it to number .map((token) => Number("0x" + token));
[Question] Here I am unable to comprehend that why is he adding "Ox" to the number? how can we determine using unicode that this is going to be emoji?
THis is unicdoe blocks from wiki (if it associates with my question in anyway)