Alan Edwardes

Cloud Software & Game Development
  • About
  • Projects
  • Blog

About the Author

Alan is a hobbyist Game Developer and a Software Engineer with 7 years of industry experience.

LinkedIn Icon Twitter Icon Steam Icon GitHub Icon YouTube Icon

Posts in 2021

  • Jenkins Library for Unreal Engine 4 on 13th of Feb
  • Three Approaches to Readable Materials in First Person Games on 7th of Feb
  • Cheap Synthetic Monitoring with AWS Lambda on 24th of Jan

Posts in 2020

  • Generating Mipmaps for Render Targets in UE4 on 24th of Dec
  • Routing DNS over HTTPS Using Raspberry Pi on 6th of Oct
  • Tips for Building Games with Unreal Engine 4 on 3rd of Oct
  • Serving Localised Assets from S3 Using Lambda@Edge on 17th of May

Posts in 2019

  • Automating macOS Notarization for UE4 on 23rd of Nov

Posts in 2018

  • ISO Country Code to Unicode Flag in C# and JavaScript on 22nd of Jul
  • Serverless Git LFS for Game Development on 6th of Jan
  • Adding Custom Map Checks in UE4 on 3rd of Jan

Posts in 2017

  • Building and Deploying a React App Using AWS Lambda on 24th of Dec
  • Git HTTP Username and Password in Environment Variables on 22nd of Dec
  • Capturing and Uploading Screenshots in UE4 on 20th of Dec
  • Using Capsule Shadows on Large Objects in UE4 on 8th of Dec

Category "c-sharp"

Viewing subset of posts filtered by category.

ISO Country Code to Unicode Flag in C# and JavaScript

Posted July 22nd, 2018, last updated July 23rd, 2020 in c-sharp

The Unicode 6.0 spec defines Regional Indicator symbols, which includes a set of flags. Here are the founders of NATO, if your system supports the flag characters (Windows 10 doesn't yet):

🇧🇪 🇨🇦 🇩🇰 🇫🇷 🇮🇸 🇮🇹 🇱🇺 🇳🇱 🇳🇴 🇵🇹 🇬🇧 🇺🇸

To create a flag, take the country ISO code (for example GB), and offset it to the flags Unicode block.

C#

public static string IsoCountryCodeToFlagEmoji(this string country)
{
    return string.Concat(country.ToUpper().Select(x => char.ConvertFromUtf32(x + 0x1F1A5)));
}

string gb = "gb".IsoCountryCodeToFlagEmoji(); // 🇬🇧
string fr = "fr".IsoCountryCodeToFlagEmoji(); // 🇫🇷

JavaScript

function isoCountryCodeToFlagEmoji(country)
{
   return String.fromCodePoint(...[...country.toUpperCase()].map(c => c.charCodeAt() + 0x1F1A5));
}

let gb = isoCountryCodeToFlagEmoji("gb"); // 🇬🇧
let fr = isoCountryCodeToFlagEmoji("fr"); // 🇫🇷

Æ

© 2021 Alan Edwardes