Will Do
Thoughts on technology, the world, and life.

How Unicode Country Flags Work

How do you encode politically-contentious country flags?

Benjamin Esham:

Version 6.0 of the Unicode standard, released in October 2010, added support for emoji. Aside from the classics like ๐Ÿ˜ƒ (SMILING FACE WITH OPEN MOUTH), ๐Ÿ‘ (THUMBS UP SIGN), and ๐Ÿ’ฉ (PILE OF POO), the standard also included several national flags like these:

๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿ‡ฉ๐Ÿ‡ช ๐Ÿ‡ฌ๐Ÿ‡ง ๐Ÿ‡ฏ๐Ÿ‡ต ๐Ÿ‡ฎ๐Ÿ‡น

In fact, the standard included every national flag, and in a way that won’t require the standard to be changed when new countries come into being. How did the Unicode Consortium pull this off?

What they did is both crazy and genius. Instead of assigning a codepoint to each flag, which is the obvious way to do it (and the way the rest of the emoji are encoded), the standard defines twenty-six “regional indicator symbols”, from U+1F1E6 REGIONAL INDICATOR SYMBOL LETTER A to U+1F1FF REGIONAL INDICATOR SYMBOL LETTER Z. In order to include a country’s flag in your text, you first look up the country’s two-letter ISO 3166-1 code and then write the two regional indicator symbols corresponding to those letters. A font with support for that flag treats the two-codepoint sequence as a ligature, replacing the combination with a single pictogram.

π