country flag emoji <-> country code
Easy as pie:
import { getEmojiFlag } from "@cprecioso/country-flag-emoji"
getEmojiFlag("ES")
getEmojiFlag("nl")
getEmojiFlag("pt-BR")
getEmojiFlag("pt-BR".slice(-2))
getEmojiFlag()
And conversely:
import { getCountryCode } from "@cprecioso/country-flag-emoji"
getCountryCode("🇪🇸")
getCountryCode("🇳🇱")
getCountryCode("🇵🇹")
getCountryCode("🇧🇷")
getCountryCode()
This package uses CharCode math ✨magic✨, and not a database, so it's extremely lightweight and never goes out-of-date. However, emoji flag <-> ISO country code
is the only feature it offers. If you need more, this is not your package.
Keep in mind that the manufacturer of your OS might choose not to display flags, displaying the country code in emoji letters instead. This is out of my control -- and basically, out of the control of anyone who is not the manufacter of your OS.