Converting ISO Country Codes to Flag Emojis 4 ▲ Dan Q 181 days ago · Tech · hide · Fediverse post Today I learned something that is probably already well-known in some circles… but I hadn’t noticed it before and it made me go “wow”: There’s a really simple algorithm for converting ISO 3166-1 alpha-2 country codes into the emoji representations of the flags of those countries. I made an interactive to show how it works (enter a two-letter country code!). There’s a longer explanation below: Here’s the essence of the algorithm: Take the two-letter country code, e.g. FR for France. Get the character code of the uppercase variant of each letter: so F becomes 70 and R becomes 82.1 Add 127,397 to each of them, so now F is 127,467 and R 127,479. Render the unicode characters at those codepoints: F turns into 🇫 and R turns into 🇷. Concatenate those characters and you get the emoji of the flag: 🇫🇷 I’ve often find things that are wonderfully clever about Unicode, but this might be my new favourite. func countryEmojiFlag(countryCode string) string { cc :=… Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town