2

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).

zahabba
  • 2,921
  • 5
  • 20
  • 33
  • Hi, not sure if you already get this working but my solution will be using String.fromCharCode more info [here](https://delicious-insights.com/en/posts/js-strings-unicode/) – Softmixt Nov 12 '21 at 15:24

0 Answers0