It's been a while since I've written about Unicode, so here's a short one about a Unicode feature I recently learned about wrapped inside an opportunity to admire the Mahjong glyphs.
Quoting Wikipedia, Mahjong is a tile-based game that was developed in the 19th century in China and has spread throughout the world. Similar to other classic games like Chess and French Playing Cards, Mahjong has its own block in Unicode (U+1F000 - U+1F02F) for all of the tiles.
The Mahjong Unicode block has a single emoji in it: the Mahjong Red Dragon (🀄). So why then does it look like text in our table instead of how emojis usually look?
This effect is achieved using a feature called Unicode variation selectors.
These codepoints are in the range U+FE00..U+FE0F. The variation selectors we're interested in today are U+FE0E and U+FE0F for “text-style” and “emoji-style” respectively.
The variation selector works by being placed after the character being modified. So the Mahjong Red Dragon in text-style would be
"🀄\uFE0E" in Python.
There's a giant list of codepoints that interact with the text and emoji variation characters, give them a look if you need this feature.
This work is licensed under