Reputation: 3231
I'm building an application that converts emoji shortnames (like :flag_cf:) and converts them through a series of operations into a hex codepoint (which are the keys in a map to return Twitter emoji/twemoji).
I have a utility (emojione.shortnameToUnicode()) that converts the shortnames into native unicode emoji, but I'm having trouble with converting the native unicode emoji into hex codepoints.
I've been using:
const unicode = emojione.shortnameToUnicode(str);
const decCodepoint = unicode.codePointAt(0);
const hexCodepoint = decCodepoint.toString(16);
This works fine when the resulting hex codepoint is a single figure. However, emoji like flags seem to have two, like :flag_cn:
is 1f1f9-1f1f7
. However, my process above would only return the first hex codepoint (namely 1f1f9
).
Upvotes: 2
Views: 557