Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert unicode point to Emoji || Symbol || Character

I want to convert Unicode Code Points Notation like "U+1F1FA U+1F1F8" to "🇺🇸".

In javaScript, what I have tried so far is

String.fromCharCode(parseInt("U+1F1FA", 16));

But this doesn't work.

like image 801
mudit_sen Avatar asked Sep 08 '25 00:09

mudit_sen


2 Answers

You can wrap the hex code in braces like this:

console.log('\u{1f1fa}\u{1f1f8}')
like image 137
Zeyar Paing Avatar answered Sep 10 '25 09:09

Zeyar Paing


You can use the static method String.fromCodePoint() to achieve this.

const us = String.fromCodePoint('0x1F1FA', '0x1F1F8');
console.log(us);
like image 23
Behemoth Avatar answered Sep 10 '25 08:09

Behemoth