SlandShow
SlandShow

Reputation: 513

How to parse emoji from Unicode charset?

Running react application. I want to convert a Unicode string into emoji. But the problem is that charset related to browser convention.

For example:

Input

'&#128511 - nice emoji!'

Output
🗿 - nice emoji!

Is there any convenient way to do it?

Upvotes: 0

Views: 644

Answers (1)

adir abargil
adir abargil

Reputation: 5745

your string can be converted that way :

String.fromCodePoint(128511)
>>> "🗿"

also your specific emoji has hex code 0x1F5FF:

`${ String.fromCodePoint(0x1F5FF)} - nice emoji!`
>>>"🗿 - nice emoji!"

you can search for hex code in this table you can yuse whatever you prefer.. just covert the number after th '&#' with String.fromCodePoint() ...

Upvotes: 1

Related Questions