meeDamian / country-emoji

Converts between country names, ISO 3166-1 codes and flag emojis.
https://www.npmjs.com/package/country-emoji
MIT License
83 stars 25 forks source link

Emoji for UK constituent countries? #34

Closed rokoroku closed 2 months ago

rokoroku commented 1 year ago

🏴󠁧󠁢󠁥󠁮󠁧󠁿 Flag: England 🏴󠁧󠁢󠁳󠁣󠁴󠁿 Flag: Scotland 🏴󠁧󠁢󠁷󠁬󠁳󠁿 Flag: Wales

Above 3 emojis are added in Emoji 5.0... and I think it can be added to the library.

BrodaNoel commented 6 months ago

@rokoroku could you please create a PR adding the flags, countries, and country codes?

meeDamian commented 2 months ago

Thank you for your request! Unfortunately, there are two main challenges with implementing this feature:

  1. Conceptual Issue: The [ISO 3166-1 alpha-2 (cca2)] standard, which this library is based on, does not include the flags you've mentioned. While it's technically possible to make exceptions, there's also the…

  2. Technical Issue: Country flag emojis are made up of exactly two cca2-mapped [regional indicator symbols] (e.g., 🇬 and 🇧, which combine to form 🇬🇧). This simplicity allows for a straightforward conversion [from country code to flag] and [back] again, using just a bit of math, with country names added as a bonus.

However, the flags you're referring to, such as the flag of England 🏴󠁧󠁢󠁥󠁮󠁧󠁿, are quite different. These flags are composed of multiple characters based on the ISO 3166-2 standard:

  1. 🏴 (U+1F3F4): Waving Black Flag
  2. (U+E0067): Tag Latin Small Letter G
  3. (U+E0062): Tag Latin Small Letter B
  4. (U+E0065): Tag Latin Small Letter E
  5. (U+E006E): Tag Latin Small Letter N
  6. (U+E0067): Tag Latin Small Letter G
  7. (U+E007F): Cancel Tag

In short, adding support for these flags would require either a completely separate codebase or filling the existing code with exceptions, which isn't ideal. For now, we'll be sticking with the current implementation.

Again, thank you for your question—I’ve learned some interesting things through this process!