// To run this on the Go Playground: https://go.dev/play/p/9na7SU0ExdD package main import "fmt" func main() { country := "PT" fmt.Printf("%s — Decimal: %d %d Hex: %#[1]x %#x\n", country, rune(country[0]), rune(country[1])) fmt.Printf("Difference: %d (hex: %#[1]x)\n", 0x1F1E6-0x0041) fmt.Printf("First letter + difference: %d (hex: %#[1]x) Type: %[1]T\n", rune(country[0])+127397) fmt.Printf("Second letter + difference: %d (hex: %#[1]x) Type: %[1]T\n", rune(country[1])+127397) fmt.Println("Flag: ", getFlag(country)) } // ISO-3166-1 two-letter country codes to flag emoji. func getFlag(countryCode string) string { // 0x1F1E6 - REGIONAL INDICATOR SYMBOL LETTER A // 0x1F1FF - REGIONAL INDICATOR SYMBOL LETTER Z // 0x0041 — LATIN CAPITAL LETTER A // 0x005A — LATIN CAPITAL LETTER Z return string(rune(countryCode[0])+127397) + string(rune(countryCode[1])+127397) }