Why UK Is Not a Valid ISO Country Code and How It Breaks Your App
ISO 3166-1 alpha-2 defines 249 officially assigned two-letter country codes, but common codes like UK and EU are not among them — they fall into reserved categories with distinct rules. The United Kingdom's official code is GB, while UK is only "exceptionally reserved" to protect the pre-existing .uk domain, meaning strict validators will reject it. Retired codes such as AN and CS still appear in legacy data but should be blocked from new user input to avoid mapping errors. Kosovo uses XK, a user-assigned code that ISO has never officially sanctioned, highlighting how disputed territories require special handling. Developers are advised to always store codes rather than country names, resolve names only at display time, and draw custom codes exclusively from the user-assigned range to avoid future collisions.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in