Skip to content

Instantly share code, notes, and snippets.

@siaw23-retired
Forked from havenwood/country_emoji.rb
Created March 24, 2020 22:20
Show Gist options
  • Save siaw23-retired/f7ff81f8c7c7eba72ce3bcc72382aa3a to your computer and use it in GitHub Desktop.
Save siaw23-retired/f7ff81f8c7c7eba72ce3bcc72382aa3a to your computer and use it in GitHub Desktop.
Country Emoji
COUNTRY_LETTERS = 'A'.upto('Z').each.with_index(127462).to_h.freeze
def country_emoji(iso)
COUNTRY_LETTERS.values_at(*iso.chars).pack('U*')
end
country_emoji('GB')
#=> "🇬🇧"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment