Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert one emoji character to Unicode codepoint number in JavaScript?

how to convert this 😀 in to this 1f600 in javascript

'😀'.charCodeAt(0);  

this will return unicode 55357 but how to get 1f600 from 😀

like image 773
Parth Gajjar Avatar asked Jan 24 '18 09:01

Parth Gajjar


People also ask

Can emojis be represented by Unicode?

No. Because emoji characters are treated as pictographs, they are encoded in Unicode based primarily on their general appearance, not on an intended semantic.

Does UTF-8 include emoji?

Emojis look like images, or icons, but they are not. They are letters (characters) from the UTF-8 (Unicode) character set.


1 Answers

Two way

let hex = "😀".codePointAt(0).toString(16)
let emo = String.fromCodePoint("0x"+hex);

console.log(hex, emo);
like image 160
Kamil Kiełczewski Avatar answered Sep 24 '22 03:09

Kamil Kiełczewski