Created
May 30, 2024 18:41
-
-
Save aseroff/c84ca75c58124257940dc184222fd654 to your computer and use it in GitHub Desktop.
Emoji flag from country code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source: https://twitter.com/yarotheslav/status/1793259765902024940 | |
def country_code_to_emoji(country_code) | |
base_emoji_code = 0x1F1E6 | |
country_code.upcase.each_char.map do |char| | |
((char.ord - 'A'.ord) + base_emoji_code).chr(Encoding::UTF_8) | |
end.join | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment