Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert Unicode to emoji in JavaScript?

I have an array with Unicode data like var data = ["1F923", "1F603"]

If I use "\u{1F923}" in console, it returns an emoji, but if I use "\u{"+ data[0] +"}", it returns an error. Can anyone please help me to convert Unicode to emoji.

like image 769
Mina Avatar asked Feb 25 '26 10:02

Mina


1 Answers

Emoji is a subset of unicode. There is no conversion from unicode to emoji necessary or possible. Just change your array to

var data = ["\u{1F923}", "\u{1F603}"]

If your input is a hex number, you can use

String.fromCodePoint(parseInt ("1F923", 16))

In HTML you can also use HTML hex entities

"&#x" + "1F923" + ";"
like image 144
RalfFriedl Avatar answered Feb 28 '26 01:02

RalfFriedl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!